converting a timezone-less datetime to seconds since the epoch
Chris Withers
chris at simplistix.co.uk
Thu Mar 18 09:44:53 EDT 2010
Hey Chris,
Chris Rebert wrote:
>> def timestamp(dttm):
>> return time.mktime(dttm.timetuple())
>
> from calendar import timegm
>
> def timestamp(dttm):
> return timegm(dttm.utctimetuple())
> #the *utc*timetuple change is just for extra consistency
> #it shouldn't actually make a difference here
Ah, right. What on earth is timegm doing in calendar?
No way I ever would have thought to look there...
I wonder what the best way to get this stuff documented in the datetime
modules docs is?
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
More information about the Python-list
mailing list