[TZInfo-users] Getting dst? for different time zones

John Lauck john-subscribed at recaffeinated.com
Mon Jul 2 13:17:22 EDT 2007


I have a list of locations and a boolean that tells me if the location
observes day light savings.  Each location is identified by a GMT offset for
its time zone.

I need to check if each time zone is currently within day light savings or
not.  I know I could simply check my local time using Time.now.dst?, but
that won't help on the day of the day light savings switch.  For instance,
if it's 2:00AM on the east coast on the day of DST "jump ahead" it becomes
3:00AM (and the time zone changes from -5 to -4), then it's still  11PM on
the west coast.  The west coast doesn't change to -7 from -8 until 2AM
within their local time.  This means it's 6:00AM on the east coast when the
west coast finally switches to DST, jumping from 2AM to 3AM hours later than
the west coast.

Although this is simply a several hour gap where a bug could occur it has to
be handled.  Ruby's Time and DateTime etc are not easy to deal with.  I've
been trying to use tzinfo, but I can't find the correct methods.  I think
I'm just not finding the correct documentation because a lot of time/date
libraries use a vocabulary that's not always familiar to everyone.


Is what I'm trying to do possible with the current Ruby libraries or do I
need tzinfo?  Does anyone know of a way to create a Time/DateTime object for
a location/time zone so I can simply use Time.dst?   ?  Also, I'd really
like to be able to use the offset integer -4...-8 (and others, limited to US
now, but could be necessary internationally) rather than using the time zone
names "America/New_York" since I don't have the offsets mapped to names.

Ideas anyone?

Thanks,

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/tzinfo-users/attachments/20070702/a7342cb2/attachment.html 


More information about the TZInfo-users mailing list