Created
September 22, 2015 04:33
-
-
Save sontek/3351aff9e48d148910d6 to your computer and use it in GitHub Desktop.
Python 3 can't handle dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
now = datetime.utcnow() | |
t = now.timestamp() | |
t2 = datetime.utcfromtimestamp(t) | |
assert now == t2, 'Why no work?' |
Author
sontek
commented
Sep 22, 2015
So during the .timestamp()
operation, it is interpreting the datetime
as in my local time zone, because the utcnow()
call is not clever enough to attach a UTC time zone to the value it returns?
Its actually even simpler, its just a rounding bug. Its losing precision during one of the calls (I'm not sure which one). The great thing is they actually did finally fix it on Friday so whenever the next release is I should finally be able to rip out all my custom date code :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment