[TZInfo-users] Misunderstanding (or bug?) with timezones from Etc/GMT+X
phil.ross at gmail.com
Sat Sep 20 11:41:02 EDT 2008
2008/9/20 Pavel Valodzka <valodzka at gmail.com>:
> For example GMT+2. It's mean european summer time, yes? When at GMT is 5
> hour, GMT+2 - 7 hour (GMT + 2 hour).
> But tzinfo thinks other - it calculat GMT+2 as GMT-2 hour:
>>> tz = TZInfo::Timezone.get 'Etc/GMT+2'
> => #<TZInfo::DataTimezone: Etc/GMT+2>
> => Sat Sep 20 12:53:07 UTC 2008
> => Sat Sep 20 14:53:12 UTC 2008
> It's bug or, may be, GMT+X mean UTC-X?
TZInfo is correct. It uses the data from the Olson tz database, which
defines the Etc/GMT+-x zones in a POSIX-compliant (and confusing)
manner. The following is taken from the definition of these zones in
the Olson database:
# We use POSIX-style signs in the Zone names and the output abbreviations,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses
# the abbreviation "GMT+4" and corresponds to 4 hours behind UTC
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UTC (i.e. east of Greenwich).
If you want to handle daylight savings automatically, then you should
use a geographical timezone (e.g. Europe/Paris) instead of the Etc
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
More information about the TZInfo-users