Skip to content

Apply timezone to parsed since timestamp#42

Open
Frost wants to merge 1 commit intomasterfrom
fix-service-view-date-parse
Open

Apply timezone to parsed since timestamp#42
Frost wants to merge 1 commit intomasterfrom
fix-service-view-date-parse

Conversation

@Frost
Copy link
Copy Markdown
Contributor

@Frost Frost commented Mar 31, 2026

The datetime.datetime.strptime function will only return naive timestamps, and those will crash in the database query later if run during times when DST is changing. It can crash with NonExistantTimeError when the clock moves forward, and with AmbiguousTimeError when the clock moves back.

Since we know(?) that we always provide a "UTC" suffix to these timestamps, I think it is safe to hardcode that we add the timezone.utc as the tzinfo to these parsed objects.

The `datetime.datetime.strptime` function will only return naive
timestamps, and those will crash in the database query later if run
during times when DST is changing. It can crash with
`NonExistantTimeError` when the clock moves forward, and with
`AmbiguousTimeError` when the clock moves back.

Since we know(?) that we always provide a "UTC" suffix to these
timestamps, I think it is safe to hardcode that we add the
`timezone.utc` as the tzinfo to these parsed objects.
@Frost Frost force-pushed the fix-service-view-date-parse branch from ad63350 to 06b34d2 Compare March 31, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant