Skip to content
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

fmt/strtime: add %V and %:V for formatting and parsing IANA time zone identifiers #75

Merged
merged 1 commit into from
Aug 3, 2024

Conversation

BurntSushi
Copy link
Owner

This matches the V specifier used by Java's formatting/parsing
infrastructure
.

The motivation for this is to bring the strtime APIs to parity with
jiff::fmt::temporal. Namely, without an IANA time zone identifier, one
cannot correctly roundtrip a Zoned value.

Jiff does support %Z when formatting for printing time zone
abbreviations like EDT or EST, but since these are ambiguous, they
aren't supported while parsing. (Perhaps we should support parsing and
validating them though, especially in conjunction with a IANA time zone
identifier.)

When using %V, if there is no IANA time zone identifier, then the
offset without colons is used instead. To get an offset with colons, use
%:V.

… identifiers

This matches the V specifier used by [Java's formatting/parsing
infrastructure][java format].

The motivation for this is to bring the strtime APIs to parity with
`jiff::fmt::temporal`. Namely, without an IANA time zone identifier, one
cannot correctly roundtrip a `Zoned` value.

Jiff does support `%Z` when formatting for printing time zone
abbreviations like `EDT` or `EST`, but since these are ambiguous, they
aren't supported while parsing. (Perhaps we should support parsing and
validating them though, especially in conjunction with a IANA time zone
identifier.)

When using `%V`, if there is no IANA time zone identifier, then the
offset without colons is used instead. To get an offset with colons, use
`%:V`.

[java format]: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/format/DateTimeFormatter.html#ISO_ZONED_DATE_TIME
@BurntSushi BurntSushi merged commit 482e2b4 into master Aug 3, 2024
17 checks passed
@BurntSushi BurntSushi deleted the ag/strtime-iana branch August 3, 2024 18:56
BurntSushi added a commit that referenced this pull request Aug 3, 2024
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