This project is archived and is in readonly mode.
ActiveSupport Date class methods seem to be buggy
Reported by Xac | November 22nd, 2010 @ 02:54 AM
There seem to be issues with Date.yesterday and Date.today:
ruby-1.8.7-p302 > Rails.version #=> "3.0.3"
ruby-1.8.7-p302 > Date.today #=> Sun, 21 Nov 2010
ruby-1.8.7-p302 > Date.yesterday #=> Sun, 21 Nov 2010
ruby-1.8.7-p302 > Date.today == Date.yesterday #=> true
ruby-1.8.7-p302 > Date.today.today? #=> false
ruby-1.8.7-p302 > Date.tomorrow #=> Tue, 23 Nov 2010
ruby-1.8.7-p302 > Time.now #=> Sun Nov 21 22:00:13 -0500
2010
ruby-1.8.7-p302 > Time.now.utc #=> Mon Nov 22 03:00:20 UTC
2010
Comments and changes to this ticket
-
Utkarsh Kukreti November 22nd, 2010 @ 06:50 PM
I'm getting
> Date.today == Date.tomorrow => true > Time.now => 2010-11-23 00:19:52 +0530 > Time.now.utc => 2010-11-22 18:49:54 UTC
Date.tomorrow and Date.yesterday are not taking the local timezone into consideration, and are using the UTC offsets.
-
agmcleod November 30th, 2010 @ 04:13 AM
I'm having issues where Date.today isn't even resolving...
aaronmcleod@MacBook-Pro $ irb ruby-1.9.2-p0 > require 'active_support' => true ruby-1.9.2-p0 > Date.today NoMethodError: undefined method `today' for Date:Class from (irb):2 from /Users/aaronmcleod/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>' ruby-1.9.2-p0 > exit aaronmcleod@MacBook-Pro $ ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] aaronmcleod@MacBook-Pro $ rails -v Rails 3.0.3
-
Xac November 30th, 2010 @ 05:35 AM
ActiveSupport is broken down into pieces that need to be individually required now.
Try "require 'active_support/core_ext/date'" for date helpers, or "require 'activesupport/all'" for the old functionality.
-
agmcleod December 1st, 2010 @ 12:30 AM
Ah alright, I have it working now. I seem to be getting the correct date & times. Note that I am in eastern standard time.
-
Rohit Arondekar January 2nd, 2011 @ 01:06 AM
- Importance changed from to Low
Xac, Utkarsh: is this an issue of bad documentation of Date.yesterday and Date.tomorrow or bugs in the methods themselves?
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>
People watching this ticket
Referenced by
- 6237 Date bug in rails 3 https://rails.lighthouseapp.com/projects/8994/tickets/60...
- 6237 Date bug in rails 3 Duplicate of #6029