This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | zooko |
|---|---|
| Recipients | zooko |
| Date | 2009年06月13日.16:48:00 |
| SpamBayes Score | 3.721794e-05 |
| Marked as misclassified | No |
| Message-id | <1244911683.12.0.112588761912.issue6280@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
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 (http://allmydata.org/trac/tahoe/browser/src/allmydata/util/time_format.py?rev=2424 ), 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 (http://allmydata.org/trac/tahoe/changeset/3911/src/allmydata/util/time_format.py ), but that doesn't work on Windows. Then there was force-the-tz-to-UTC-except-on-Windows (http://allmydata.org/trac/tahoe/changeset/3913/src/allmydata/util/time_format.py ), 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 (http://allmydata.org/trac/tahoe/changeset/3914/src/allmydata/util/time_format.py ). 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 (http://allmydata.org/trac/tahoe/changeset/3915/src/allmydata/util/time_format.py ) I suggest that timegm() be moved to the time module next to its sibling gmtime(). |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009年06月13日 16:48:03 | zooko | set | recipients: + zooko |
| 2009年06月13日 16:48:03 | zooko | set | messageid: <1244911683.12.0.112588761912.issue6280@psf.upfronthosting.co.za> |
| 2009年06月13日 16:48:01 | zooko | link | issue6280 messages |
| 2009年06月13日 16:48:00 | zooko | create | |