Arlen Cuss
10/25/2007 11:45:00 AM
On Thu, 2007-10-25 at 20:00 +0900, Casimir wrote:
> What units does it output - with .to_f or .to_i?
That's seconds since the UNIX Epoch -- 1st of January, 1970.
irb(main):003:0> now = Time.now.to_i
=> 1193313074
irb(main):004:0> #wait a few seconds
irb(main):005:0> later = Time.now.to_i
=> 1193313084
irb(main):006:0> later - now
=> 10
irb(main):007:0>
Of course, it's totally unnecessary to cast, since the same thing
happens when you do it directly:
irb(main):008:0> now = Time.now
=> Thu Oct 25 21:51:48 +1000 2007
irb(main):009:0> later = Time.now
=> Thu Oct 25 21:51:52 +1000 2007
irb(main):010:0> later - now
=> 3.621771
irb(main):011:0>
And defaults to better precision! (unless you pick .to_f, the only
difference I mean. But it's semantically better this way.)
Arlen