Time zone offset and daylight saving

My understanding is that a time change is implemented by switching time
zones; you change from Pacific Standard Time to Pacific Daylight Time.
Pacific Standard Time would continue to have the same offset in July as it
would in January; it's just that in July no clocks are set to Pacific
Standard. (Except the clock on my kitchen scale, of course...)

And good luck figuring out when you're supposed to switch; it's arbitary,
set by legislation, not by something you can figure out. And the US at
least will be changing in the near future. And there are places that never
make the switch, too. Google for things like 'daylight savings time zone'
and you'll get an idea of the pain involved.

- James

<easleydp@gmail.com> wrote in message
news:1138565845.900427.111410@g14g2000cwa.googlegroups.com...

···

I don't seem to be able to correctly calculate the time offset between
two time zones when daylight saving is in effect. The code below
demonstrates that Ruby knows about daylight saving, but I get the wrong
answer when I calculate the offset.

BTW, yes, I know I can use Time#utc_offset, but I believe that depends
on me actually being in that timezone. I'm looking for a way to
calculate the offset between two arbitrary timezones, neither of which
is my local timezone.

Thanks for any help.

David

Thanks for the help, guys.

Took a look at the Python port of the tz database, then discovered
there's a Ruby version! Check out these links:

Rubyforge: http://tzinfo.rubyforge.org/
How to use with Rails:
http://lunchroom.lunchboxsoftware.com/pages/tzinfo_rails

The TZInfo lib for Ruby does a pretty good job of encapsulating all those rules:

   http://tzinfo.rubyforge.org/

- Jamis

···

On Feb 1, 2006, at 2:38 PM, JM wrote:

My understanding is that a time change is implemented by switching time
zones; you change from Pacific Standard Time to Pacific Daylight Time.
Pacific Standard Time would continue to have the same offset in July as it
would in January; it's just that in July no clocks are set to Pacific
Standard. (Except the clock on my kitchen scale, of course...)

And good luck figuring out when you're supposed to switch; it's arbitary,
set by legislation, not by something you can figure out. And the US at
least will be changing in the near future. And there are places that never
make the switch, too. Google for things like 'daylight savings time zone'
and you'll get an idea of the pain involved.

- James

<easleydp@gmail.com> wrote in message
news:1138565845.900427.111410@g14g2000cwa.googlegroups.com...

I don't seem to be able to correctly calculate the time offset between
two time zones when daylight saving is in effect. The code below
demonstrates that Ruby knows about daylight saving, but I get the wrong
answer when I calculate the offset.

BTW, yes, I know I can use Time#utc_offset, but I believe that depends
on me actually being in that timezone. I'm looking for a way to
calculate the offset between two arbitrary timezones, neither of which
is my local timezone.

Thanks for any help.

David

Hi,

Regarding "good luck figuring out when you're supposed to switch" - Phil Ross has released a ruby library that uses the Olson Timezone database (considered the definitive source for world timezones).

You're right that it's a pain (it's a political issue after all) but it's not insurmountable if you use the Olson data.

Phil's library is available at:

http://tzinfo.rubyforge.org/

HTH,
Trevor

···

On 1-Feb-06, at 1:38 PM, JM wrote:

My understanding is that a time change is implemented by switching time
zones; you change from Pacific Standard Time to Pacific Daylight Time.
Pacific Standard Time would continue to have the same offset in July as it
would in January; it's just that in July no clocks are set to Pacific
Standard. (Except the clock on my kitchen scale, of course...)

And good luck figuring out when you're supposed to switch; it's arbitary,
set by legislation, not by something you can figure out. And the US at
least will be changing in the near future. And there are places that never
make the switch, too. Google for things like 'daylight savings time zone'
and you'll get an idea of the pain involved.

- James

<easleydp@gmail.com> wrote in message
news:1138565845.900427.111410@g14g2000cwa.googlegroups.com...

I don't seem to be able to correctly calculate the time offset between
two time zones when daylight saving is in effect. The code below
demonstrates that Ruby knows about daylight saving, but I get the wrong
answer when I calculate the offset.

BTW, yes, I know I can use Time#utc_offset, but I believe that depends
on me actually being in that timezone. I'm looking for a way to
calculate the offset between two arbitrary timezones, neither of which
is my local timezone.

Thanks for any help.

David

--
Trevor Squires
http://somethinglearned.com