Bug in Time module, or in my understanding?

Hamilton, William whamil1 at entergy.com
Thu Aug 2 11:26:09 EDT 2007


> From: Joshua J. Kugler
> 
> I am getting results like these with the time module:
> 
> >>> import time
> >>> int(time.mktime(time.strptime('2007-03-11 02:00:00', '%Y-%m-%d
%H:%M
> %S')))
> 1173610800
> >>> int(time.mktime(time.strptime('2007-03-11 03:00:00', '%Y-%m-%d
%H:%M
> %S')))
> 1173610800
> >>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173610800))
> '2007-03-11 03:00:00'
> 
> I know it probably has something to do with daylight savings, but how
can
> I
> get back out that which I put in?  The times concerned are all
standard
> time, so how can I keep the time module from asserting its belief that
I
> want to convert to daylight savings?
> 
> Incidentally, it only happens with times on 2007-03-11  from 02:00:00
to
> 02:59:59, and not with time data from past years.
> 

I get similar results, except with hours 01:00:00 and 02:00:00.  I am in
US Central time (GMT-6).

>>> int(time.mktime(time.strptime('2007-03-11 00:00:00','%Y-%m-%d
%H:%M:%S')))
1173592800
>>> int(time.mktime(time.strptime('2007-03-11 01:00:00','%Y-%m-%d
%H:%M:%S')))
1173596400
>>> int(time.mktime(time.strptime('2007-03-11 02:00:00','%Y-%m-%d
%H:%M:%S')))
1173596400
>>> int(time.mktime(time.strptime('2007-03-11 03:00:00','%Y-%m-%d
%H:%M:%S')))
1173600000


--
-Bill Hamilton



More information about the Python-list mailing list