NO TICKET: update all datetime fields to be timezone aware in the database and schemas#65
Merged
Merged
Conversation
Data must be timezone aware. If it is not UTC it gets converted to UTC.
And default to UTC
chasetmartin
approved these changes
Aug 7, 2025
Collaborator
There was a problem hiding this comment.
I tried to replicate the error I was getting on sample edit, and this fixed the issue. The response is returning the timezone, so even when the user does no editing before save, the front end now send back the expected format via the roundtrip. 👍
One question: is PastDatetime a built in Pydantic validator to check that the datetime is not in the future?
Contributor
Author
|
PastDatetime is a built-in Pydantic validator (and type) to ensure that the supplied datetime is not in the future. This is what an error looks like from it (status code is still 422)
|
jirhiker
approved these changes
Aug 8, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
DateTimecolumns toDateTime(timezone=True)TIMESTAMPcolumns toTIMESTAMP(timezone=True)func.now()tofunc.timezone("UTC", func.now()to ensure that the time zone is UTC. It defaults to the time zone of the database forfunc.now()so this change ensures the stored time zone is UTC if that is not how it is set in the db.pydantic.AwareDatetimeinstead ofdatetime.datetimeto require time zone aware fields to be passed and returnedAnnotatedfield validationsNotes
Any special considerations, workarounds, or follow-up work to note?
ZnotationAwareDatetimeresponses to UTC? Just to be extra safe.