Tim Peters wrote:
> Not sure when this started to fail -- "recently":
> Failure in test testParseTimeZoneNames
> (zope.i18n.tests.test_formats.TestDateTimeFormat)
> Traceback (most recent call last):
>   File "C:\Code\Zope3\src\zope\i18n\tests\test_formats.py", line 306,
> in testParseTimeZoneNames
>     self.assertEqual(dt.tzinfo.utcoffset(dt), datetime.timedelta(hours=-6))
>   File "C:\python23\lib\unittest.py", line 302, in failUnlessEqual
>     raise self.failureException, \
> AssertionError: datetime.timedelta(-1, 67200) != datetime.timedelta(-1, 64800)
> Not sure what the test case is testing either:
>     def testParseTimeZoneNames(self):
>         dt = self.format.parse('01.01.2003 09:48 EST', 'dd.MM.yyyy HH:mm zzz')
>         self.assertEqual(dt.tzinfo.utcoffset(dt), 
> datetime.timedelta(hours=-6))
> EST is 5 hours west of UTC, so I'm not sure why -6 would be expected. 
> The minus 5 hours and 20 minutes it's getting back doesn't seem right
> either ;-)

Actually, EST is 5 hours west of UTC, and 10 hours east of UTC, and 11 hours
east of UTC.

What was happening is that self.format.parse() is constructing a localtime
datetime instance without invoking the pytz localize() method to bind the
correct timezone information (as documented in the pytz README.txt and on
http://pytz.sourceforge.net )

So the new Olson release says that Eastern Standard Time only started being
UTC-0500 in 1908, and prior to that people actually thought noon was when
the sun was directly overhead (UTC-0520). When the datetime is constructed
in a local timezone (rather than converted from UTC), you get arbitrary
tzinfo information because no pytz code is invoked so no calculations can be
done to determine the correct timezone information to use for that datetime.
The localize() method is a workaround for this. I really need to knock up a
PEP detailing the hooks required in the datetime library to get this all
working seemlessly so I can deprecate localize() and normalize() from pytz.

Anyway - I've fixed the broken code and updated the tests. My fault for not
running the tests - most of my time is spent with a system that runs the
tests for me before accepting my commit and my brain had not fully context

Stuart Bishop <[EMAIL PROTECTED]>

Attachment: signature.asc
Description: OpenPGP digital signature

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to