This project is archived and is in readonly mode.
Time.zone.today returns Date instead of ActiveSupport::TimeWithZone
Reported by Carlos Rodriguez | February 18th, 2010 @ 02:01 AM
Time.zone.now returns an ActiveSupport::TimeWithZone object
Time.zone.parse('02/17/2010') returns an
ActiveSupport::TimeWithZone object
Time.zone.today returns a Date object
This means that you can do this:
Time.zone.parse('02/17/2010').beginning_of_day and have it return the correct time.
But you can't do this:
Time.zone.today.beginning_of_day and have it return the correct time.
Is this the expected behavior or is this a bug?
Comments and changes to this ticket
-
Andrew White March 25th, 2010 @ 07:11 PM
You can however do Time.zone.now.beginning_of_day, which is what Time.zone.today would likely be if it returned an ActiveSupport::TimeWithZone instance.
-
Jeremy Kemper March 29th, 2010 @ 07:50 AM
- State changed from new to wontfix
Expected behavior. #today returns Date.
-
Kyle J. Ginavan March 29th, 2010 @ 04:17 PM
I missing something here. Within my 2.3.3 application I have a test that compares two reports. I pull it using sql/ActiveRecord::Base.connection.select_value with Time.zone.now.beginning_of_year.utc then compare to a report using pure active record and Time.zone.now.beginning_of_year. All is well.
Whenever I try to upgrade to 2.3.4 or 2.3.5 this breaks and I'm unable to put my finger on the issue or how the heck to fix. This is why I +1'd this ticket. Anyone have any insights?
-
Andrew White March 29th, 2010 @ 04:36 PM
You could use the Github compare view to look for any commits that might have affected your reports: http://github.com/rails/rails/compare/v2.3.3...v2.3.4 and http://github.com/rails/rails/compare/v2.3.4...v2.3.5
There are a couple of commits to do with date/time calculation that could be affecting you.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>