Python 2.1 and Daylight saving time

skip at pobox.com skip at pobox.com
Wed Mar 7 17:07:38 EST 2007


removing webmaster email address...

Others reading this with more experience manipulating timezones please
reply.  This is completely out of the realm of my experience, but since I
pointed Wayne here from the webmaster mailing list I felt I should respond.
What I've written is based solely on reading a bit of the current time
module documentation and peeking at the time module source
(ever-so-briefly).

    Wayne> I mainly needed to know if I could avert Daylight Saving Time
    Wayne> issues by upgrading to Python 2.5.

    Wayne> It appears that Python gets it UTC settings from a table in the C
    Wayne> library. Does this still hold true for Python 2.5. It looks that
    Wayne> it will fail to recognize the new DST 2007 changes.

Python's timezone code is reliant on the functions provided by your system's
libc routines.  Starting in Python 2.3 if your system has a working tzset()
function in libc the time module exposes a tzset() function which you can
use to change the rules used by your system.  If your system's timezone
information hasn't been updated I imagine you could coax the correct
behavior out of your application with tzset().  I suggest you read the
relevant documentation

    http://docs.python.org/dev/lib/module-time.html

before contemplating upgrading from 2.1 to something more recent and/or
modifying your application to use tzset().  Given the minimal amount of time
between now and Sunday morning I suspect your best chance of correct
operation will be to have the correct timezone tables installed on your
computer.

Skip



More information about the Python-list mailing list