Skip to content

Instantly share code, notes, and snippets.

@haluzpav
Created February 16, 2019 16:54
Show Gist options
  • Save haluzpav/b9eb401a136fe8730acc383031186b56 to your computer and use it in GitHub Desktop.
Save haluzpav/b9eb401a136fe8730acc383031186b56 to your computer and use it in GitHub Desktop.
Jsons bug - wrongly serialized utc datetime
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