nicolas.glondu at mlstate.com
Tue Jan 31 20:36:52 UTC 2012
Le 31/01/2012 20:09, Owen Gunden a écrit :
> Is there any support for handling timezones? I don't see anything in
> the Date module.
> I need to get a GMT time on a server where the system clock is in EST.
> I happen to know what the offset is so I could do it by hand (with
> Date.shift_forward), but it would be nice if the code were robust to
> different server timezones (e.g. running in the cloud).
While waiting, if you want a hack that will work on any timezones, you
can use the number of hours of epoch:
If above 12, you are likely in GMT-something and GMT+something below 12
(some extremal timezones may fail but this can be fixed easily if it's
really a problem)
Which gives (in old syntax) :
n = Date.get_hour(Date.epoch)
if n < 12 then n
Hope it helps.
Nicolas 'HenJi' Glondu
More information about the Opa