-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: datetime -> Aware for created/last_modified #1155
refactor: datetime -> Aware for created/last_modified #1155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add either a validator to coerce the timezone to utc, or a custom serializer so that the string representation is always in UTC. There is a discussion why it is useful to keep the timestamp string representations in DocDB sortable: https://stackoverflow.com/questions/38497442/what-is-the-best-way-to-store-datetime-value-in-documentdb
Do you know how times in docdb get the ms information? Just want to make sure the final output is in the right format. |
@helen-m-lin Do you know? I'm pretty sure they just take the json we send them. When we write to DocDB, we first run |
Yeah, the datestamps are being stored as strings in docdb. I'm finding that the serialization is not consistent where some have UTC timezone and some do not. I'll send some examples offline. |
Sounds like we should add a |
Sounds good. Saskia has an example here:
|
|
We don't want to use UTC. we want tz_aware. |
These are for timestamps specific to what's getting stored in DocDB. We want those in a consistent serialized format to make them sortable. |
@jtyoung84 @helen-m-lin is this still waiting on something? I think I cleared out all the requested changes |
This PR refactors the created/last_modified fields to use
AwareDatetimeWithDefault
to force users to include timezone information or have it added automatically.Note that there are still a lot of places in the code where people are using
datetime.utcnow.isoformat()
which returns a naive datetime object without timezone information. Everybody needs to switch to usingdatetime.now(timezone.utc).isoformat()