[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: converting a timezone-less datetime to seconds since the epoch

Chris Withers

3/18/2010 1:45:00 PM

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.simpli...