The ruby way : DateTime calculations?


#1

Is there an existent lib or such that gives me some date/time
calculations ?

Time.now - 2.minutes for instance ?

Thanks,


#2

On Monday 21 November 2005 3:48 pm, Peter F. wrote:

Is there an existent lib or such that gives me some date/time calculations
?

Time.now - 2.minutes for instance ?

Time.now - 2 * 60

or

(some people would argue that this is the best approach)

Minute = 60
Hour = Minute * 60
Day = Hour * 24
Time.now - 2 * Minute

or

The ActiveSupport library for Rails has those sorts of methods defined.

or

I think Facets might have these, too.

or

Roll your own. They are easy to write.

Kirk H.


#3

On 11/21/05, Peter F. removed_email_address@domain.invalid wrote:

Is there an existent lib or such that gives me some date/time calculations ?

Time.now - 2.minutes for instance ?

ActiveSupport, which is part of Rails, has this stuff. Take a look:

http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Numeric/Time.html#M000234

Ryan