[Bug?] Time utils lose DST information

Amit Patel amitp at Xenon.Stanford.EDU
Tue Apr 4 22:55:08 EDT 2000


First, my program:

from time import *

print strftime("%a %b %d %H:%M:%S %Y", 
               localtime(mktime(strptime("Mon Apr 3 05:06:07 2000"))))

I'd like this to return "Mon Apr 3 05:06:07 2000".

However, it doesn't.  It returns "Mon Apr 3 06:06:07 2000".

I found this odd, so I looked at the Python 1.6a1 source... strptime
leaves the daylight savings (DST) flag as 0 (known to NOT be DST)
instead of -1 (unknown status of DST).  (strptime (in timemodule.c)
fills in the structure with 0's, and C's strptime doesn't set this
flag unless you use a %Z in the time format.)

Given that strptime doesn't know the DST status, I think it should
initialize the `tm' structure to contain -1 in the DST field,
indicating "unknown", so that converting to and back from Unix time
doesn't give the wrong number.

Any thoughts on this?


   -i'd-rather-absolish-daylight-savings-completely-y'rs, Amit



More information about the Python-list mailing list