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.
3203ed0e608d3bfae1e31282e629ffa2?d=identicon&s=25 peter.fitzgibbons (Guest)
on 2005-11-21 23: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,
1b5341b64f7ce0244366eae17f06c801?d=identicon&s=25 khaines (Guest)
on 2005-11-22 00:12
(Received via mailing list)
On Monday 21 November 2005 3:48 pm, Peter Fitzgibbons 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 Haines
4b174722d1b1a4bbd9672e1ab50c30a9?d=identicon&s=25 leavengood (Guest)
on 2005-11-22 00:16
(Received via mailing list)
On 11/21/05, Peter Fitzgibbons <peter.fitzgibbons@gmail.com> 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.