myusuf3 / delorean

Delorean: Time Travel Made Easy
http://delorean.rtfd.org/
MIT License
1.84k stars 128 forks source link

epoch issue? #31

Closed b1-88er closed 9 years ago

b1-88er commented 11 years ago

In [57]: Delorean(datetime.now(), timezone='UTC').epoch() - time.time() Out[57]: 7199.999927997589

In [58]: time.mktime(Delorean(datetime.now(), timezone='UTC').datetime.timetuple()) - time.time() Out[58]: 3599.633516073227

mlew commented 9 years ago

This issue is invalid. datetime.timetuple() returns a localized timetuple. Try the following, substituting your local timezone for 'US/Pacific'.

>>> d = Delorean(datetime(2015, 1, 1), timezone='US/Pacific')
>>> d.epoch()
1420099200.0
>> time.mktime(d.datetime.timetuple())
1420099200.0
b1-88er commented 9 years ago

Thanks!

myusuf3 commented 9 years ago

That in a nutshell is why I dislike datetime. :100: Thanks for the quick response there @mlew