Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JSON serialisation fails if models have timestamp objects as values. #23

Open
smn opened this issue Sep 23, 2014 · 3 comments
Open

JSON serialisation fails if models have timestamp objects as values. #23

smn opened this issue Sep 23, 2014 · 3 comments

Comments

@smn
Copy link
Contributor

smn commented Sep 23, 2014

We should probably change the field type to just work with iso-strings (so we can json encode easily) but provide helpers for getting the actual datetime object.

>>> page = PageModel(modified_at='2014-09-19T00:00:00.000+00:00')
>>> print page.modified_at
'2014-09-19T00:00:00.000+00:00'
>>> print page.modified_at.datetime()
datetime.datetime(2014, 9, 19, 00, 00, 00, 000, tzinfo=tzoffset(None, 0))
>>>

Not having this caused major issues in Vumi.

@hodgestar & @jerith any suggestions from you guys considering the Vumi trouble?

@hodgestar
Copy link
Contributor

My vote would be to serialize (and store) timestamps as UNIX timestamps in milliseconds. This is perhaps a topic better discussed over lunch, but in short:

  • timestamps are simple and easily parsed
  • there is any easy mapping to and from UTC
  • milliseconds feel like a good level of granularity (too much happens in 1s and nanoseconds take one into regimes where defining what "current time" means becomes tricky)

@miltontony
Copy link
Contributor

@smn didn't you resolve this?

@smn
Copy link
Contributor Author

smn commented Oct 7, 2014

Nope, it's still an issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants