Skip to content

Specify well-formed values for timezones, calendars & units#1104

Merged
eemeli merged 3 commits intomainfrom
well-formed-options
Mar 16, 2026
Merged

Specify well-formed values for timezones, calendars & units#1104
eemeli merged 3 commits intomainfrom
well-formed-options

Conversation

@eemeli
Copy link
Copy Markdown
Collaborator

@eemeli eemeli commented Mar 6, 2026

Closes #935
Closes #936
See also #961 (comment)
Closes #962

As resolved on this week's call, the options for which we accept values defined elsewhere should all be spec'd as "well-formed" rather than "valid". As we do not mandate that all well-formed values are accepted without error, or that the errors emitted for "not well-formed" and "not valid" are different from each other, this allows for a linter/validator to detect not-well-formed values early, while not requiring a formatting implementation to differentiate well-formed-but-not-valid from not-well-formed values.

While the spec text does not make mention of Unicode short time zone identifiers, it should be noted that all such values are technically well-formed time zone identifiers according to RFC 9557. This means that an implementation could support such values, but they would probably not work in all implementations. If we'd like to discourage this, I think including a non-normative note to that effect might be appropriate (suggestions for exact text are most welcome).

This PR also addresses #961 (comment) by defining the behaviour when formatting date/time values that do not include a time zone.

Copy link
Copy Markdown
Member

@aphillips aphillips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. Generally looks very good. I support the direction this is taking.

Co-authored-by: Addison Phillips <[email protected]>
@eemeli eemeli requested a review from aphillips March 6, 2026 21:52
@macchiati
Copy link
Copy Markdown
Member

A couple of comments.

  1. There are 10 different formatting options for timezones in CLDR. It should be possible for an implementation to support those in formatting dates, without a lot of hassle. Otherwise this would be

  2. While of course the TZDB IDs are paramount, it should also be possible for an implementation to support the short CLDR ids.

Can you sketch out how that would be done?

(In general, the more limitations the spec has compared to MF1, the harder it is to make a case for migration to MF2.)

Cf. @sffc, @robertbastian

@eemeli
Copy link
Copy Markdown
Collaborator Author

eemeli commented Mar 7, 2026

There are 10 different formatting options for timezones in CLDR. It should be possible for an implementation to support those in formatting dates, without a lot of hassle. Otherwise this would be

The formatting of timezones is outside the scope of this PR; for that we've timeZoneStyle, which currently supports only long and short as values. We could expand that set, but discussions about that should be separated from this discussion.

While of course the TZDB IDs are paramount, it should also be possible for an implementation to support the short CLDR ids.

As noted in previous discussions, e.g. #962 (comment), we have concerns about the use of short ids for interchange beyond ICU implementations. Therefore, it would be most appropriate for Someone™ to start drafting icu: namespace extensions to the spec...

If this Someone™ ends up being the MFWG rather than the ICU-TC, then we should probably consider using the u: namespace for optional options that introduce a hard dependency on ICU or CLDR data.

This distinction is intended to ensure that interoperable non-ICU implementations of Unicode MessageFormat remain possible.

@rxaviers

This comment was marked as off-topic.

@macchiati
Copy link
Copy Markdown
Member

As noted in previous discussions, e.g. #962 (comment), we have concerns about the use of short ids for interchange beyond ICU implementations. Therefore, it would be most appropriate for Someone™ to start drafting icu: namespace extensions to the spec...

True, that would be a way to support the additional features. I should have phrased my comment differently; the main point is that lacking those features will imped migration.

Copy link
Copy Markdown
Collaborator

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also happy with this direction.

a _Bad Operand_ error is emitted and the default time zone is used to format the _expression_.

If the _resolved value_ of the _operand_ does not include a time zone or offset,
the _resolved value_ of the `timeZone` _option_ is used as its time zone.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to have this language than not, but it doesn't answer #961.

Comment on lines +281 to +283
> [!NOTE]
> A date/time type encapsulating a Unix time is considered to include UTC as its time zone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is talking about Java Date, it seems better to use the local time zone than UTC.

Co-authored-by: Richard Gibson <[email protected]>
Co-authored-by: Eemeli Aro <[email protected]>
@eemeli eemeli merged commit dd86e42 into main Mar 16, 2026
2 checks passed
@eemeli eemeli deleted the well-formed-options branch March 16, 2026 19:44
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.

[FEEDBACK] Be more specific about time zone IDs Add short timezone identifiers Well-formed vs valid

6 participants