On Apr 7, 9:57 am, Chris Withers wrote:
> Chris Rebert wrote:
> > To convert from struct_time in ***UTC***
> > to seconds since the epoch
> > use calendar.timegm()
>
> ...and really, wtf is timegm doing in calendar rather than in time? ;-)
You're not alone in finding this strange: http://bugs.pyt
Hi Chris,
Chris Rebert wrote:
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
And problem solved. As for what the problem was:
Paraphrasing the table
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, righ
On Tue, Mar 16, 2010 at 6:47 AM, Chris Withers wrote:
> Hi All,
>
> We have a bunch of datetime objects that have tzinfo=None.
> We want to turn them into float timestamps in seconds since the epoch.
>
> Here's the first attempt:
>
> import time
> from datetime import datetime
> from unittest impo