[Chicago] Daylight Savings Time in Python

Allan Spale allan2600 at gmail.com
Wed Aug 19 17:44:30 CEST 2009


Hello,

I am doing some historical (i.e. current year and earlier years) date-time
comparisons that need to be fairly accurate on the order of milliseconds.
One of the date-time values is already in a format of seconds since the UN*X
epoch. However, the other is a string of the format YYYYMMDDHHMMSS. I plan
to use time.strptime(date, "%Y%m%d%H%M%S") to receive a time tuple that I
can then send to time.mktime(time_tuple). It should be noted that the eighth
item in the tuple (the daylight savings time flag) is set to -1 that will
have time.mktime() calculate how to apply the daylight savings time rule.

This seems all fine and good until I thought about some daylight savings
time change that occurred in 2007 (
http://aa.usno.navy.mil/faq/docs/daylight_time.php). 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)?

Thanks for your help.


Allan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090819/fc6607a0/attachment.htm>


More information about the Chicago mailing list