Forum: Ruby The ruby way : DateTime calculations ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
peter.fitzgibbons (Guest)
on 2005-11-22 00:51
(Received via mailing list)
Is there an existent lib or such that gives me some date/time
calculations ?

Time.now - 2.minutes for instance ?

Thanks,
khaines (Guest)
on 2005-11-22 01:12
(Received via mailing list)
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.
leavengood (Guest)
on 2005-11-22 01:16
(Received via mailing list)
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/C...

Ryan
This topic is locked and can not be replied to.