Skip to content

fmt/strtime: make strptime with Zoned and only %s work#433

Merged
BurntSushi merged 1 commit intomasterfrom
ag/unknown-timezone-strptime-timestamp
Oct 18, 2025
Merged

fmt/strtime: make strptime with Zoned and only %s work#433
BurntSushi merged 1 commit intomasterfrom
ag/unknown-timezone-strptime-timestamp

Conversation

@BurntSushi
Copy link
Copy Markdown
Owner

Previously, if %s was parsed and there was no offset (%z) or IANA
time zone identifier (%Q), then trying to pull a Zoned out of a
BrokenDownTime would fail. But arguably, this should work. Namely, the
strptime APIs are already very relaxed about returning a Zoned with
fixed offset time zones (where the normal FromStr APIs forbid it due
to footguns). And since we have a way of representing an unknown time
zone, we can do exactly that.

Previously, if `%s` was parsed and there was no offset (`%z`) or IANA
time zone identifier (`%Q`), then trying to pull a `Zoned` out of a
`BrokenDownTime` would fail. But arguably, this should work. Namely, the
`strptime` APIs are already very relaxed about returning a `Zoned` with
fixed offset time zones (where the normal `FromStr` APIs forbid it due
to footguns). And since we have a way of representing an unknown time
zone, we can do exactly that.
@BurntSushi BurntSushi merged commit 23cdd25 into master Oct 18, 2025
39 checks passed
@BurntSushi BurntSushi deleted the ag/unknown-timezone-strptime-timestamp branch October 18, 2025 19:04
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