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

Support short localized GMT format and GMT format with seconds #5638

Closed
sffc opened this issue Oct 2, 2024 · 9 comments · Fixed by #5641 or #5674
Closed

Support short localized GMT format and GMT format with seconds #5638

sffc opened this issue Oct 2, 2024 · 9 comments · Fixed by #5641 or #5674
Assignees
Labels
C-time-zone Component: Time Zones U-ecma402 User: ECMA-402 compatibility

Comments

@sffc
Copy link
Member

sffc commented Oct 2, 2024

https://unicode.org/reports/tr35/tr35-dates.html#Using_Time_Zone_Names says:

Localized GMT format: A constant, specific offset from GMT (or UTC), which may be in a translated form. There are two styles for this. The first is used when there is an explicit non-zero offset from GMT; this style is specified by the element and element. The long format always uses 2-digit hours field and minutes field, with optional 2-digit seconds field. The short format is intended for the shortest representation and uses hour fields without leading zero, with optional 2-digit minutes and seconds fields. The digits used for hours, minutes and seconds fields in this format are the locale's default decimal digits:

  • "GMT+03:30" (long)
  • "GMT+3:30" (short)
  • "UTC-03.00" (long)
  • "UTC-3" (short)
  • "Гринуич+03:30" (long)

However, currently we only support the "long" format, and we don't support offsets with hours only (the spec doesn't say how to do that: presumably use FixedDecimalFormatter directly??) or hours, minutes, and seconds (although there are no examples of this in the spec, and the data has only hours and minutes).

2.0 to check if we need to add data to TimeZoneEssentialsV1. Otherwise, 2.x priority because ECMAScript will need this.

CC @robertbastian

@sffc sffc added U-ecma402 User: ECMA-402 compatibility C-time-zone Component: Time Zones labels Oct 2, 2024
@sffc sffc added this to the ICU4X 2.0 ⟨P1⟩ milestone Oct 2, 2024
@robertbastian
Copy link
Member

I already have code for this.

@robertbastian
Copy link
Member

seconds (although there are no examples of this in the spec, and the data has only hours and minutes).

No timezone that I know of has a sub-minute UTC offset, so the "optional seconds" are never required (they're not in the pattern anyway).

we don't support offsets with hours only (the spec doesn't say how to do that: presumably use FixedDecimalFormatter directly??)

My solution is to ignore everything between the hours and minutes field of the pattern. We need to use the pattern because it contains the +/- signs.

@sffc
Copy link
Member Author

sffc commented Oct 3, 2024

seconds (although there are no examples of this in the spec, and the data has only hours and minutes).

No timezone that I know of has a sub-minute UTC offset, so the "optional seconds" are never required (they're not in the pattern anyway).

But you can construct one and they are in Temporal

(They were routinely used before trains were invented)

@sffc sffc reopened this Oct 3, 2024
@robertbastian
Copy link
Member

(They were routinely used before trains were invented)

No time zone has ever been defined with a sub-minute offset to UTC. The local times that were used before international standardisation have a sub-minute offset to UTC, but they were defined as "the time at my observatory". All of this stopped being used well before the UNIX epoch (i.e. in late 19th/early 20th century), and while the TZDB shoehorns these time zones into UTC offsets, we have in multiple places made the decision that correctness before 1970 is not a goal of ICU4X.

But you can construct one and they are in Temporal

Well, again, the patterns in CLDR don't include seconds. ISO patterns support seconds, localized formats don't.

@anba
Copy link

anba commented Oct 3, 2024

Africa/Monrovia has sub-minute offsets after 1970. (Not sure if that case is relevant here, though.)

@sffc
Copy link
Member Author

sffc commented Oct 9, 2024

How to reproduce sub-minute offset formatting in Chrome:

new Intl.DateTimeFormat("en-US", {
  timeZone: "Europe/Amsterdam",
  dateStyle: "full",
  timeStyle: "full"
}).format(new Date(1800, 0, 1))

@robertbastian
Copy link
Member

Ok, but we need a pattern for that. Will need to discuss with CLDR

@robertbastian
Copy link
Member

robertbastian commented Oct 9, 2024

  • Inconsistent with duration formatter (i.e. . separator in Serbian duration, but : in time zones)
  • No seconds support
  • Patterns control padding, however the spec prescribes padding already (2 digits for long and 0 for short)

@robertbastian
Copy link
Member

Also for CLDR discussion, from #5656:

  • Add strings for "Unknown Timezone" and "GMT+?"

robertbastian added a commit that referenced this issue Oct 11, 2024
* Exemplar cities should now be called locations (#5657)
* Region patterns can live in the locations struct
* Offset pattern can be split into signs and separator (#5638)
sffc added a commit that referenced this issue Oct 14, 2024
Fixes #5638

---------

Co-authored-by: Shane F. Carr <shane@unicode.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-time-zone Component: Time Zones U-ecma402 User: ECMA-402 compatibility
Projects
None yet
3 participants