babel icon indicating copy to clipboard operation
babel copied to clipboard

FixedOffsetTimezone.utcoffset() is the negative of pytz.StaticTzInfo.utcoffset()

Open moreati opened this issue 10 years ago • 0 comments

I believe these should represent the same fixed timezone, i.e. 1 hour ahead of GMT

>>> babel_tz = babel.util.FixedOffsetTimezone(60)
>>> babel_tz
<FixedOffset "Etc/GMT+60" 1:00:00>
>>> pytz_tz = pytz.timezone('Etc/GMT+1')
>>> pytz_tz
<StaticTzInfo 'Etc/GMT+1'>

but they each calculate the opposite of the other as the UTC offset, given a datetime

>>> dt = datetime(2001,1,31)
>>> babel_tz.utcoffset(dt)
datetime.timedelta(0, 3600)
>>> pytz_tz.utcoffset(dt)
datetime.timedelta(-1, 82800)
>>> babel_tz.utcoffset(dt) == -pytz_tz.utcoffset(dt)
True

moreati avatar Sep 10 '15 19:09 moreati