[Python-Dev] datetime module enhancements

Christian Heimes lists at cheimes.de
Sun Mar 11 02:27:59 CET 2007


Tristan Seligmann wrote:
> Unfortunately, it would appear that the Olson tz database contains some
> rather... uh... confusing data. For example:
> 
>>>> pytz.timezone('Africa/Johannesburg')
> <DstTzInfo 'Africa/Johannesburg' SAST+1:30:00 STD>
> # SAST is UTC+2 not UTC+1.5

The tz of Africa/Johannesburg initially started with an offset of 1h30
before 1903. It looks like a bug in pytz

>>> dt = datetime(2007, 3, 11, 0, 0, 0)
>>> aj = pytz.timezone("Africa/Johannesburg")
>>> aj.utcoffset(dt)
datetime.timedelta(0, 5400)

should be 7200 seconds in 2007

>>>> pytz.timezone('Etc/GMT+2')._utcoffset
> datetime.timedelta(-1, 79200)

That's another bug. Side note: You shouldn't access the _utcoffset
attribute. The offset may depend on the date.

I notified Stuart about the two issues in his package.

Christian



More information about the Python-Dev mailing list