-
-
Notifications
You must be signed in to change notification settings - Fork 36
Define time zone values and conversions #1078
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -282,11 +282,14 @@ the functions `:datetime`, `:date`, and `:time`. | |||||||||||||||||||
- `local` | ||||||||||||||||||||
- `UTC` | ||||||||||||||||||||
|
||||||||||||||||||||
> [!NOTE] | ||||||||||||||||||||
> The value `local` permits a _message_ to convert a date/time value | ||||||||||||||||||||
> into a [floating](https://www.w3.org/TR/timezone/#floating) time value | ||||||||||||||||||||
> (sometimes called a _plain_ or _local_ time value) by removing | ||||||||||||||||||||
> the association with a specific time zone. | ||||||||||||||||||||
The value `local` corresponds to the default time zone. | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value
The above formats as "June 28, 2025" regardless of where the message is viewed, vs. potentially formatting as "June 29, 2025" or "June 27, 2025" depending on the default time zone. The name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, so We should probably use a different term that is more implicitly obvious about its meaning. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As expressed elsewhere, I hate the term |
||||||||||||||||||||
|
||||||||||||||||||||
If the _operand_ value does not include a time zone, | ||||||||||||||||||||
it 10000 is presumed to use the default time zone. | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's not clear here if "the default time zone" is meant to be the result of accessing the system time zone setting, or a single default time zone (e.g. UTC). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intent with the proposed language is to match the text from earlier in the same section: message-format-wg/spec/functions/datetime.md Lines 265 to 268 in 0028d17
Does that context clarify the meaning here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ah, I missed that. How about this, then? |
||||||||||||||||||||
If the _operand_ value does include a time zone and the `timeZone` _option_ is set, | ||||||||||||||||||||
an implementation SHOULD convert the value to the time zone indicated by the _option_. | ||||||||||||||||||||
Comment on lines
+287
to
+290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this reads oddly, since the result of the first sentence would be that all operands end up with a time zone. Lots of operands do not "include" a time zone--all classical date/time values, such as JS
I would say:
Suggested change
Note that it is unclear what "convert" means and the conversion means different things depending on the operand type. See here for examples of types. The conversion is one thing for a floating time or an incremental time/timestamp (you just add the time zone to the value) but requires calculation through a calendar for "zoned" values. The value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This does no
927D
t match my understanding of what would happen if a time without an explicit timezone (such as a JS With the JS Intl.DateTimeFormat, this happens: const now = new Date()
new Intl.DateTimeFormat('en-de',{timeStyle:'long'}).format(now)
// "11:10:55 CEST"
new Intl.DateTimeFormat('en-de',{timeZone:'America/Los_Angeles',timeStyle:'long'}).format(now)
// "02:10:55 GMT-7" So effectively the date being formatted is always considered to use the local/system time zone, and setting My strong preference would be for the MF2 Do the ICU datetime formatters use a similar approach, or do they do something different? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you're right. And ICU does it the same way. It's my description that is somewhat wonky. If you have a timestamp, you always need a calendar to format the value, but the application of a time zone (the default or some explicit value) doesn't change the timestamp itself. If you have a "zoned" value, you use a calendar to compute the instant and then modify the value by applying the explicitly provided time zone (you wouldn't use the default zone with a zoned value, presumably). |
||||||||||||||||||||
If such conversion is not supported, an implementation MAY alternatively | ||||||||||||||||||||
emit a _Bad Option_ error and use a _fallback value_ as the _resolved value_ of the _expression_. | ||||||||||||||||||||
|
||||||||||||||||||||
The following _option_ is REQUIRED to be available on | ||||||||||||||||||||
the functions `:datetime` and `:time`: | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I like the ident "local"; that word is way overloaded. I think "system" or "default" would be better.