-
-
Notifications
You must be signed in to change notification settings - Fork 36
Include :date, :datetime, and :time with minimal options #1083
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -2,10 +2,6 @@ | |
|
|
||
| This subsection describes the _functions_ and _options_ for date/time formatting. | ||
|
|
||
| > [!IMPORTANT] | ||
| > The _functions_ in this section have a status of **Draft**. | ||
| > They are proposed for inclusion in a future release and are not Stable. | ||
|
|
||
| > [!NOTE] | ||
| > Selection based on date/time types is not required by this release of MessageFormat. | ||
| > Use care when defining implementation-specific _selectors_ based on date/time types. | ||
|
|
@@ -14,15 +10,14 @@ This subsection describes the _functions_ and _options_ for date/time formatting | |
|
|
||
| #### The `:datetime` function | ||
|
|
||
| The function `:datetime` is used to format date/time values, including | ||
| the ability to compose user-specified combinations of fields. | ||
| The function `:datetime` is used to format both the date and time of a date/time value. | ||
|
|
||
| If no options are specified, this function defaults to the following: | ||
|
|
||
| - `{$d :datetime}` is the same as `{$d :datetime dateStyle=medium timeStyle=short}` | ||
| - `{$d :datetime}` is the same as `{$d :datetime dateFields=year-month-day timePrecision=minute}` | ||
|
|
||
| > [!NOTE] | ||
| > The default formatting behavior of `:datetime` is inconsistent with `Intl.DateTimeFormat` | ||
| > The formatting behavior of `:datetime` is inconsistent with `Intl.DateTimeFormat` | ||
| > in JavaScript and with `{d,date}` in ICU MessageFormat 1.0. | ||
| > This is because, unlike those implementations, `:datetime` is distinct from `:date` and `:time`. | ||
|
|
||
|
|
@@ -35,93 +30,39 @@ All other _operand_ values produce a _Bad Operand_ error. | |
|
|
||
| ##### Options | ||
|
|
||
| The `:datetime` function can use either the appropriate _style options_ | ||
| or can use a collection of _field options_ (but not both) to control the formatted | ||
| output. | ||
| _Date/time override options_ can be combined with either _style options_ or _field options_. | ||
|
|
||
| If both _style options_ and _field options_ are specified, | ||
| a _Bad Option_ error is emitted | ||
| and a _fallback value_ used as the _resolved value_ of the _expression_. | ||
|
|
||
| If the _operand_ of the _expression_ is an implementation-defined date/time type, | ||
| it can include _style options_, _field options_, or other _options_. | ||
| These are included in the resolved option values of the _expression_, | ||
| with _options_ on the _expression_ taking priority over any options of the _operand_. | ||
|
|
||
| > [!NOTE] | ||
| > The names of _options_ and their _option values_ were derived from the | ||
| > [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#description) | ||
| > in JavaScript's `Intl.DateTimeFormat`. | ||
|
|
||
| ###### Style Options | ||
|
|
||
| **_<dfn>Style options</dfn>_** pertain to the overall styling or appearance of the formatted output. | ||
|
|
||
| The following _style options_ are REQUIRED to be available on the function `:datetime`: | ||
|
|
||
| - `dateStyle` | ||
| - `full` | ||
| - `long` | ||
| - `medium` | ||
| - `short` | ||
| - `timeStyle` | ||
| - `full` | ||
| - `long` | ||
| - `medium` | ||
| - `short` | ||
|
|
||
| ###### Field Options | ||
|
|
||
| **_<dfn>Field options</dfn>_** describe which fields to include in the formatted output | ||
| and what format to use for that field. | ||
|
|
||
| > [!NOTE] | ||
| > _Field options_ do not have default values because they are only to be used | ||
| > to compose the formatter. | ||
|
|
||
| The following _field options_ are REQUIRED to be available on the function `:datetime`: | ||
|
|
||
| - `weekday` | ||
| - `long` | ||
| - `short` | ||
| - `narrow` | ||
| - `era` | ||
| - `long` | ||
| - `short` | ||
| - `narrow` | ||
| - `year` | ||
| - `numeric` | ||
| - `2-digit` | ||
| - `month` | ||
| - `numeric` | ||
| - `2-digit` | ||
| The following _options_ are REQUIRED to be available on the function `:datetime`: | ||
|
|
||
| - `dateFields` | ||
| - `day` | ||
| - `weekday` | ||
| - `day-weekday` | ||
| - `month-day` | ||
| - `month-day-weekday` | ||
| - `year-month-day` (default) | ||
| - `year-month-day-weekday` | ||
| - `dateLength` | ||
| - `long` | ||
| - `medium` (default) | ||
| - `short` | ||
| - `narrow` | ||
| - `day` | ||
| - `numeric` | ||
| - `2-digit` | ||
| - `hour` | ||
| - `numeric` | ||
| - `2-digit` | ||
| - `minute` | ||
| - `numeric` | ||
| - `2-digit` | ||
| - `second` | ||
| - `numeric` | ||
| - `2-digit` | ||
| - `fractionalSecondDigits` | ||
| - `1` | ||
| - `2` | ||
| - `3` | ||
| - `timeZoneName` | ||
| - `timePrecision` | ||
| - `hour` | ||
| - `minute` (default) | ||
| - `second` | ||
| - `timeZoneStyle` | ||
| - `never` (default) | ||
| - `long` | ||
| - `short` | ||
| - `shortOffset` | ||
| - `longGeneric` | ||
| - `longOffset` | ||
| - `short` | ||
| - `shortGeneric` | ||
| - `longGeneric` | ||
| - `shortOffset` | ||
| - _Date/time override options_ | ||
|
|
||
| If the _operand_ of the _expression_ is an implementation-defined date/time type, | ||
| it can include other option values. | ||
| Any _date/time override options_ of the operand are included in the resolved option values of the _expression_, | ||
| with _options_ on the _expression_ taking priority over any options of the _operand_. | ||
| Any _operand_ options not matching the _date/time override options_ are ignored. | ||
|
|
||
| ##### Resolved Value | ||
|
|
||
|
|
@@ -136,7 +77,7 @@ The function `:date` is used to format the date portion of date/time values. | |
|
|
||
| If no options are specified, this function defaults to the following: | ||
|
|
||
| - `{$d :date}` is the same as `{$d :date style=medium}` | ||
| - `{$d :date}` is the same as `{$d :date fields=year-month-day length=medium}` | ||
|
|
||
| ##### Operands | ||
|
|
||
|
|
@@ -147,19 +88,27 @@ All other _operand_ values produce a _Bad Operand_ error. | |
|
|
||
| ##### Options | ||
|
|
||
| The function `:date` has these _options_: | ||
|
|
||
| - `style` \[REQUIRED\] | ||
| - `full` | ||
| The following _options_ are REQUIRED to be available on the function `:date`: | ||
|
|
||
| - `fields` | ||
| - `day` | ||
| - `weekday` | ||
| - `day-weekday` | ||
| - `month-day` | ||
| - `month-day-weekday` | ||
| - `year-month-day` (default) | ||
| - `year-month-day-weekday` | ||
| - `length` | ||
| - `long` | ||
| - `medium` (default) | ||
| - `short` | ||
| - _Date/time override options_ | ||
|
|
||
| If the _operand_ of the _expression_ is an implementation-defined date/time type, | ||
| it can include other option values. | ||
| Any _operand_ options matching the `:datetime` _style options_ or _field options_ are ignored, | ||
| as is any `style` option. | ||
| Any _date/time override options_ of the operand are included in the resolved option values of the _expression_, | ||
| with _options_ on the _expression_ taking priority over any options of the _operand_. | ||
| Any _operand_ options not matching the _date/time override options_ are ignored. | ||
|
|
||
| ##### Resolved Value | ||
|
|
||
|
|
@@ -176,7 +125,7 @@ The function `:time` is used to format the time portion of date/time values. | |
|
|
||
| If no options are specified, this function defaults to the following: | ||
|
|
||
| - `{$t :time}` is the same as `{$t :time style=short}` | ||
| - `{$t :time}` is the same as `{$t :time precision=minute timeZoneStyle=never}` | ||
|
|
||
| ##### Operands | ||
|
|
||
|
|
@@ -187,19 +136,27 @@ All other _operand_ values produce a _Bad Operand_ error. | |
|
|
||
| ##### Options | ||
eemeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The function `:time` has these _options_: | ||
| The following _options_ are REQUIRED to be available on the function `:time`: | ||
|
|
||
| - `style` \[REQUIRED\] | ||
| - `full` | ||
| - `precision` | ||
| - `hour` | ||
| - `minute` (default) | ||
| - `second` | ||
| - `timeZoneStyle` | ||
|
Member
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. timeZoneStyle or zoneStyle?
Collaborator
Author
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.
Member
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 experimental ICU4X syntax uses |
||
| - `never` (default) | ||
|
||
| - `long` | ||
| - `medium` | ||
| - `short` (default) | ||
| - `longGeneric` | ||
| - `longOffset` | ||
| - `short` | ||
| - `shortGeneric` | ||
| - `shortOffset` | ||
|
||
| - _Date/time override options_ | ||
|
|
||
| If the _operand_ of the _expression_ is an implementation-defined date/time type, | ||
| it can include other option values. | ||
| Any _operand_ options matching the `:datetime` _style options_ or _field options_ are ignored, | ||
| as is any `style` option. | ||
| Any _date/time override options_ of the operand are included in the resolved option values of the _expression_, | ||
| with _options_ on the _expression_ taking priority over any options of the _operand_. | ||
| Any _operand_ options not matching the _date/time override options_ are ignored. | ||
|
|
||
| ##### Resolved Value | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.