Time.today going away
Eric Hodel | Mon, 08 Oct 2007 22:22:32 GMT
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
t = Time.now
t - (t.to_i % 86400)
end unless Time.respond_to? :today
Go ahead and throw it in wherever you think is appropriate. I suggest you do this now.
UPDATED: Now with a better Time::today.
Comments 
Ben Mabey said 23 minutes later
Sebastian said about 1 hour later
Eric Hodel said about 1 hour later
dlh said about 1 hour later
dlh said about 1 hour later
Eric Hodel said about 2 hours later
Comments are disabled

Articles