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...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: converting a timezone-less datetime to seconds since the epoch
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password