[Chicago] Daylight Savings Time in Python

Garrett Smith g at rre.tt
Wed Aug 19 18:15:31 CEST 2009


On Wed, Aug 19, 2009 at 10:44 AM, Allan Spale<allan2600 at gmail.com> wrote:

<snip>

> So, if I am using at
> least Python 2.5, do the Python date and time modules calculate daylight
> savings time through operating system calls or is there internal code that
> performs these calculations? If Python figures out time changes internally,
> how does it update these time rules for each year (e.g. before the rules
> changed for daylight savings time and after the rule change)?

Based on the 2.6 source code it looks like the DST rules are hardcoded in C :)

This looks like it might help:

http://labix.org/python-dateutil

It uses the zoneinfo database, which should contain far more current
info than whatever version of Python is installed. At least it pushes
the problem off to the OS.


More information about the Chicago mailing list