G
Greg Lorriman
I am trying to efficiently get the date part of a Time object.
To remove the time part of the Time object I subtract the modulo of a
day-in-seconds. But if I do this I get a Time object of the date *plus
1 hour*!!! Perhaps I'm just tired, but I don;t understand why.
ie :
DAY_IN_SECS=60*60*24;
t=Time.parse("20-Oct-2005 04:04:00")
datePart=t-t.to_f.modulo(DAY_IN_SECS);
(and I might apply Time.at to get a Time object rather than a float.)
However, the result of the above is
20-Oct-2005 01:00:00
instead of
20-Oct-2005 00:00:00
Anyone got any ideas?
Greg
To remove the time part of the Time object I subtract the modulo of a
day-in-seconds. But if I do this I get a Time object of the date *plus
1 hour*!!! Perhaps I'm just tired, but I don;t understand why.
ie :
DAY_IN_SECS=60*60*24;
t=Time.parse("20-Oct-2005 04:04:00")
datePart=t-t.to_f.modulo(DAY_IN_SECS);
(and I might apply Time.at to get a Time object rather than a float.)
However, the result of the above is
20-Oct-2005 01:00:00
instead of
20-Oct-2005 00:00:00
Anyone got any ideas?
Greg