ActiveSupport Time Extensions

ruby

Mon Jun 22 20:20:19 -0700 2009

It’s no secret that I try to avoid requiring ActiveSupport when I can. But one thing I do really like about it is the time capabilities. Stuff lke this:

def fresh?
  updated_at > 1.hour.ago
end

The good news is, you can pull in just the time extensions without requiring the rest of ActiveSupport (which bloats your program, and clobbers the json gem). All you need is this:

require 'active_support/core_ext/time'