Author zooko
Recipients zooko
Date 2009-06-13.16:48:00
SpamBayes Score 3.72179e-05
Marked as misclassified No
Message-id <>
I've been struggling to write a function that takes UTC timestamps in
ISO-8601 strings and returns UTC timestamps in unix-seconds-since-epoch.
 The first implementation used time.mktime() minus time.timezone
), but that doesn't work in London if the argument date is in a certain
period during the 1970's.  Then there was force-the-tz-to-UTC
), but that doesn't work on Windows.  Then there was
), but that still doesn't work on Windows.  Then there was this horrible
hack of converting from string-iso-8601 to localseconds with
time.mktime(), then converting from the resulting localseconds to an
iso-8601 string, then converting the resulting string back to seconds
with time.mktime(), then subtracting the two seconds values to find out
the real offset between UTC-seconds and local-seconds for the current tz
and for the time indicated by the argument
).  This actually works everywhere, but it is horrible.  Finally,
yesterday, someone pointed out to me that the inverse of time.gmtime()
is located in the "calendar" module and is named calendar.timegm().  Now
the implementation of our function is simple
)  I suggest that timegm() be moved to the time module next to its
sibling gmtime().
Date User Action Args
2009-06-13 16:48:03zookosetrecipients: + zooko
2009-06-13 16:48:03zookosetmessageid: <>
2009-06-13 16:48:01zookolinkissue6280 messages
2009-06-13 16:48:00zookocreate