Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Time.zone.today returns Date instead of ActiveSupport::TimeWithZone

#3987

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?

Reported by Carlos Rodriguez · February 18th, 2010 @ 02:01 AM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Kyle J. Ginavan
  2. Ryan Felton
  3. Andrew White
    Andrew White

    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.

    March 25th, 2010 @ 07:11 PM

  4. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to wontfix

    Expected behavior. #today returns Date.

    March 29th, 2010 @ 07:50 AM

  5. Kyle J. Ginavan
    Kyle J. Ginavan

    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?

    March 29th, 2010 @ 04:17 PM

  6. Andrew White
    Andrew White

    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.

    March 29th, 2010 @ 04:36 PM