On Mon, Jul 24, 2006 at 01:08:39AM +0200, Florent Guillaume wrote: > Sorry about the offtopic, but can anyone shed some light on this: > > >>> import pytz > >>> from datetime import datetime > >>> tz = pytz.timezone('Europe/Paris'); print datetime(2006, 7, 1, > tzinfo=tz).utcoffset() > 0:09:00 > I expected 1 hour, not 9 minutes???
Read pytz/README.txt. You're not supposed to pass tzinfo to datetime. You're supposed to write >>> tz = pytz.timezone('Europe/Paris') >>> print tz.localize(datetime(2006, 7, 1)) 2:00:00 As you can see, in summer the offset is 2 hours due to daylight savings. The author of pytz claims that it is impossible to make datetime(..., tzinfo=some_tz) do the right thing because of the way the datetime module is designed. This is all very sad. :( Also be careful and avoid expressions like >>> print datetime(2006, 7, 1).replace(tzinfo=tz).utcoffset() > Am I to assume the pytz databases are buggy? I'm using a zope 3.3 > checkout. pytz gets its database from the public-domain Olson time zone database that is very extensive and widely used. See http://en.wikipedia.org/wiki/Zoneinfo Marius Gedminas -- Remember, drive defensively! And of course, the best defense is a good offense!
Description: Digital signature
_______________________________________________ Zope3-dev mailing list Zope3firstname.lastname@example.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com