Forum: Ruby Time class and time zones

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.
311e09a61c1d72c25c99d8f6bb580d28?d=identicon&s=25 Ed Lau (edlau)
on 2006-05-15 10:40
Question in brief:
Is it possible to create a Time object with a time zone other than the
local time zone or GMT?

I'm relatively new to Ruby (coming from the Java world), and after
reading the docs and playing with Time a fair bit, I've decided that you
can't create a Time object with an arbitrary time zone. Is this correct?

For example, let's say my local time zone is PDT (GMT-8). Can I create a
Time object representing 16:00 EDT (GMT-5) in New York? Sure, I know I
can represent that time as 13:00 PDT or 21:00 GMT, but that's not what I
want to do.

I'm writing an app that deals with user time zones across the globe. If
I normalize my users' times to local or GMT, I lose information. I.e., I
would like my app to remember times exactly as it was input--if a time
was input as Eastern Time (US), it should be displayed as Eastern Time
upon retrieval. Can I store the time zone datum in the Time object, or
must I persist an addition time zone field along with the Time object?
The downside to keeping track of the time zone externally is that I
can't take advantage of Time's format method and it just seems kludgy in
general.

I'd appreciate any feedback. Perhaps I'm going about this the wrong way.
Thanks much!

--Ed Lau
A87f7a014c624587fab0d3d78c5b9c18?d=identicon&s=25 Bil Kleb (Guest)
on 2006-05-15 11:08
(Received via mailing list)
Ed Lau wrote:
> Question in brief:
> Is it possible to create a Time object with a time zone other than the
> local time zone or GMT?

Slightly tangential to your question, but they might lead to
some ideas:

  http://redhanded.hobix.com/inspect/showingPerfectTime.html
  http://redhanded.hobix.com/bits/showingPerfectTime...

Regards,
74361169979a843b3a5c12d81000debc?d=identicon&s=25 Jon Egil Strand (Guest)
on 2006-05-15 16:43
(Received via mailing list)
Check out http://tzinfo.rubyforge.org/


TZInfo is a Ruby library that uses the standard tz (Olson) database to
provide daylight savings aware transformations between times in
different
time zones. The tz database is compiled into Ruby classes which are
packaged in the release. No external zoneinfo files are required at
runtime.

All the best
JE
0ca6e5c33d7e7ff901d75ff0b13d9e1c?d=identicon&s=25 Sam Roberts (Guest)
on 2006-05-16 06:36
(Received via mailing list)
Quoting jes@luretanker.no, on Mon, May 15, 2006 at 11:40:18PM +0900:
>
> Check out http://tzinfo.rubyforge.org/
>
>
> TZInfo is a Ruby library that uses the standard tz (Olson) database to
> provide daylight savings aware transformations between times in different
> time zones. The tz database is compiled into Ruby classes which are
> packaged in the release. No external zoneinfo files are required at
> runtime.

Hey, thats great! I've wanted to make vPim timezone-aware for a while,
but haven't had the energy. It looks like it won't be too hard with
this.

Thanks,
Sam
This topic is locked and can not be replied to.