This post originated from an RSS feed registered with Ruby Buzz
by Eric Hodel.
Original Post: Time.today going away
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
So you’ve been using Time::today for some time, and thought it was part of time.rb or ActiveSupport? Well, you’d be wrong. I was!
It turns out that rubygems/specification.rb defines Time::today, and that’s wrong. RubyGems has no business adding methods to the core when it doesn’t need to, so I’ve marked it for removal.
If you want to use Time::today in the future you’ll need to define it in your code somewhere, here is its definition:
require 'time'
def Time.today
Time.parse Time.now.strftime("%Y-%m-%d")
end unless Time.respond_to? :today
Go ahead and throw it in wherever you think is appropriate. I suggest you do this now.