No handling seconds jump tho:
>>> from datetime import datetime, timedelta >>> dt = datetime(2008,12,31,23,59,59) >>> str(dt) '2008-12-31 23:59:59' >>>
darn.
EDIT - @Mark: The docs say yes, but the code says not so much:
>>> time.strptime("2008-12-31 23:59:60","%Y-%m-%d %H:%M:%S") (2008, 12, 31, 23, 59, 60, 2, 366, -1) >>> time.mktime(time.strptime("2008-12-31 23:59:60","%Y-%m-%d %H:%M:%S")) 1230789600.0 >>> time.gmtime(time.mktime(time.strptime("2008-12-31 23:59:60","%Y-%m-%d %H:%M:%S"))) (2009, 1, 1, 6, 0, 0, 3, 1, 0) >>> time.localtime(time.mktime(time.strptime("2008-12-31 23:59:60","%Y-%m-%d %H:%M:%S"))) (2009, 1, 1, 0, 0, 0, 3, 1, 0)
I would think that gmtime or localtime will take the value returned by mktime and return the original tuple, and 60 as the number of seconds. And this test shows that these seconds of jump can just disappear ...
>>> a = time.mktime(time.strptime("2008-12-31 23:59:60","%Y-%m-%d %H:%M:%S")) >>> b = time.mktime(time.strptime("2009-01-01 00:00:00","%Y-%m-%d %H:%M:%S")) >>> a,b (1230789600.0, 1230789600.0) >>> ba 0.0