Python timezone parsing and Planet Sun

Posted on Jun 28, 2004

A couple of people have complained about incorrect article dates on Planet Sun - articles being sent into the near future. After spending a little time tracking it down I’m reasonably convinced that the Python module that parses RFC 822 dates is wrong. Worse, it seems that it was correct in Python 1.5 and broken in 1.5.1.

The Planet Planet code attempts to normalize all times to the time of the local machine (in this case that’s BST). It uses the rfc822.mktime_tz() to account for the fact that the original time might have included a timezone specifier, but the offset from UTC that is calculated is subtracted from the specified time. Given that zones west of UTC are already mapped to a negative offset, this results in pushing the time forward by exactly the amount it should be going backward.

Well, that’s how it seems to me. The rfc822 module on the machine that runs Planet Sun is updated and I’ll see how it fares for a couple of days before reporting back to the Python maintainers.