Created
February 16, 2019 16:54
-
-
Save haluzpav/b9eb401a136fe8730acc383031186b56 to your computer and use it in GitHub Desktop.
Jsons bug - wrongly serialized utc datetime
This file contains 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
import datetime | |
import jsons | |
# sanity check: | |
# my local time is 17:48:34, in +1 time-zone | |
dt_local = datetime.datetime.now() | |
print(dt_local) | |
# >>> 2019-02-16 17:48:34.714603 | |
print(jsons.dump(dt_local)) | |
# >>> 2019-02-16T17:48:34+01:00 | |
dt_utc = datetime.datetime.utcnow() | |
print(dt_utc) | |
# >>> 2019-02-16 16:48:34.715108 | |
print(jsons.dump(dt_utc)) | |
# >>> 2019-02-16T16:48:34+01:00 | |
# this last one is clearly wrong |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment