Time & timezones

Hi…

It’s time again to call upon the higher powers for enlightenment, bear
with me for I’m still a novice :wink:

In internet data (mail/news/logs/…) one handles many time/date
stamps from different timezones.
ParseDate does an amazing job of parsing, but I don’t know what
to do with the result.
In order to compare points in time one has to convert all the stamps
to one time zone, e.g. convert them all to GMT/UTC,
but… how do I do this in Ruby?

Class Time doesn’t provide a function to create a new one with
the values from ParseDate (timezone!) - at least I wasn’t successful
with the 10 parameter form of .gm ?!?

Bonus question: Is there a function which outputs a Time object
in RFC form (date -R on Linux prompt), as strftime with %Z gives a name,
not easier (re)parseable numbers for timezone?

Thanks!
Martin

Hi,

In internet data (mail/news/logs/…) one handles many time/date
stamps from different timezones.
ParseDate does an amazing job of parsing, but I don’t know what
to do with the result.
In order to compare points in time one has to convert all the stamps
to one time zone, e.g. convert them all to GMT/UTC,
but… how do I do this in Ruby?

Time#gmtime

Class Time doesn’t provide a function to create a new one with
the values from ParseDate (timezone!) - at least I wasn’t successful
with the 10 parameter form of .gm ?!?

require ‘time’

puts Time.parse(“Tue Jan 14 14:02:43 JST 2003”).gmtime # => Tue Jan 14 05:02:43 UTC 2003
puts Time.parse(“Tue Jan 14 14:02:43 PDT 2003”).gmtime # => Tue Jan 14 21:02:43 UTC 2003

Bonus question: Is there a function which outputs a Time object
in RFC form (date -R on Linux prompt), as strftime with %Z gives a name,
not easier (re)parseable numbers for timezone?

require ‘time’

puts Time.now.rfc822

···

At Sun, 12 Jan 2003 09:27:18 +0900, Martin Pirker wrote:


Nobu Nakada

[existence of Time.parse .rfc822 etc.]

a surprise to me

i looked at the PiR 0.4 references and then at the list in shim-ruby for
upcoming features in 1.8 but these are nowhere mentioned

lesson learned today: Ruby docs are outdated, look at the lib code for
“bonus” functions

thanks for help!
Martin

···

nobu.nokada@softhome.net wrote:

At Sun, 12 Jan 2003 09:27:18 +0900,