@@ -5,24 +5,31 @@ This subsection describes the _functions_ and _options_ for date/time formatting
55> [ !IMPORTANT]
66> The _ functions_ in this section have a status of ** Draft** .
77> They are proposed for inclusion in a future release and are not Stable.
8+ > The _ options_ and _ option values_ used by ` :datetime ` , ` :date ` , and ` :time `
9+ > are based on [ Semantic Skeletons] , which are in technical preview.
10+ > The set of _ options_ and _ option values_ will be extended by later versions of this specification.
811
912> [ !NOTE]
1013> Selection based on date/time types is not required by this release of MessageFormat.
1114> Use care when defining implementation-specific _ selectors_ based on date/time types.
1215> The types of queries found in implementations such as ` java.time.TemporalAccessor `
1316> are complex and user expectations might be inconsistent with good I18N practices.
1417
18+ [ Semantic Skeletons ] : https://www.unicode.org/reports/tr35/tr35-75/tr35-dates.html#Semantic_Skeletons
19+
1520#### The ` :datetime ` function
1621
17- The function ` :datetime ` is used to format date/time values, including
18- the ability to compose user-specified combinations of fields.
22+ The function ` :datetime ` is used to format a date/time value.
23+ Its formatted result will always include both the date and the time,
24+ and optionally a timezone.
1925
2026If no options are specified, this function defaults to the following:
2127
22- - ` {$d :datetime} ` is the same as ` {$d :datetime dateStyle=medium timeStyle=short} `
28+ - ` {$d :datetime} ` is the same as<br >
29+ ` {$d :datetime dateFields=year-month-day timePrecision=minute} `
2330
2431> [ !NOTE]
25- > The default formatting behavior of ` :datetime ` is inconsistent with ` Intl.DateTimeFormat `
32+ > The formatting behavior of ` :datetime ` is inconsistent with ` Intl.DateTimeFormat `
2633> in JavaScript and with ` {d,date} ` in ICU MessageFormat 1.0.
2734> This is because, unlike those implementations, ` :datetime ` is distinct from ` :date ` and ` :time ` .
2835
@@ -35,93 +42,42 @@ All other _operand_ values produce a _Bad Operand_ error.
3542
3643##### Options
3744
38- The ` :datetime ` function can use either the appropriate _ style options_
39- or can use a collection of _ field options_ (but not both) to control the formatted
40- output.
41- _ Date/time override options_ can be combined with either _ style options_ or _ field options_ .
42-
43- If both _ style options_ and _ field options_ are specified,
44- a _ Bad Option_ error is emitted
45- and a _ fallback value_ used as the _ resolved value_ of the _ expression_ .
46-
47- If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
48- it can include _ style options_ , _ field options_ , or other _ options_ .
49- These are included in the resolved option values of the _ expression_ ,
50- with _ options_ on the _ expression_ taking priority over any options of the _ operand_ .
51-
52- > [ !NOTE]
53- > The names of _ options_ and their _ option values_ were derived from the
54- > [ options] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#description )
55- > in JavaScript's ` Intl.DateTimeFormat ` .
56-
57- ###### Style Options
45+ The following _ options_ are REQUIRED to be available on the function ` :datetime ` :
5846
59- ** _ <dfn >Style options</dfn >_ ** pertain to the overall styling or appearance of the formatted output.
60-
61- The following _ style options_ are REQUIRED to be available on the function ` :datetime ` :
62-
63- - ` dateStyle `
64- - ` full `
47+ - ` dateFields `
48+ - ` weekday `
49+ - ` day-weekday `
50+ - ` month-day `
51+ - ` month-day-weekday `
52+ - ` year-month-day ` (default)
53+ - ` year-month-day-weekday `
54+ - ` dateLength `
6555 - ` long `
66- - ` medium `
56+ - ` medium ` (default)
6757 - ` short `
68- - ` timeStyle `
69- - ` full `
58+ - ` timePrecision `
59+ - ` hour `
60+ - ` minute ` (default)
61+ - ` second `
62+ - ` timeZoneStyle `
7063 - ` long `
71- - ` medium `
7264 - ` short `
65+ - _ Date/time override options_
7366
74- ###### Field Options
75-
76- ** _ <dfn >Field options</dfn >_ ** describe which fields to include in the formatted output
77- and what format to use for that field.
78-
79- > [ !NOTE]
80- > _ Field options_ do not have default values because they are only to be used
81- > to compose the formatter.
67+ If the ` timeZoneStyle ` _ option_ is not included in the _ expression_ ,
68+ its formatted result will not include a timezone indicator.
8269
83- The following _ field options_ are REQUIRED to be available on the function ` :datetime ` :
70+ Except for _ date/time override options_ ,
71+ each ` :datetime ` _ option value_ MUST be set by a _ literal_ .
72+ If such an _ option value_ is a _ variable_ ,
73+ a _ Bad Option Error_ is emitted and
74+ the _ option_ is ignored when formatting the _ expression_ .
8475
85- - ` weekday `
86- - ` long `
87- - ` short `
88- - ` narrow `
89- - ` era `
90- - ` long `
91- - ` short `
92- - ` narrow `
93- - ` year `
94- - ` numeric `
95- - ` 2-digit `
96- - ` month `
97- - ` numeric `
98- - ` 2-digit `
99- - ` long `
100- - ` short `
101- - ` narrow `
102- - ` day `
103- - ` numeric `
104- - ` 2-digit `
105- - ` hour `
106- - ` numeric `
107- - ` 2-digit `
108- - ` minute `
109- - ` numeric `
110- - ` 2-digit `
111- - ` second `
112- - ` numeric `
113- - ` 2-digit `
114- - ` fractionalSecondDigits `
115- - ` 1 `
116- - ` 2 `
117- - ` 3 `
118- - ` timeZoneName `
119- - ` long `
120- - ` short `
121- - ` shortOffset `
122- - ` longOffset `
123- - ` shortGeneric `
124- - ` longGeneric `
76+ If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
77+ it can include other option values.
78+ Any _ date/time override options_ of the operand are included in the resolved option values of the _ expression_ ,
79+ with _ options_ on the _ expression_ taking priority over any options of the _ operand_ .
80+ Any _ operand_ options not matching the _ date/time override options_ are ignored.
12581
12682##### Resolved Value
12783
@@ -136,7 +92,7 @@ The function `:date` is used to format the date portion of date/time values.
13692
13793If no options are specified, this function defaults to the following:
13894
139- - ` {$d :date} ` is the same as ` {$d :date style =medium} `
95+ - ` {$d :date} ` is the same as ` {$d :date fields=year-month-day length =medium} `
14096
14197##### Operands
14298
@@ -147,19 +103,31 @@ All other _operand_ values produce a _Bad Operand_ error.
147103
148104##### Options
149105
150- The function ` :date ` has these _ options _ :
106+ The following _ options _ are REQUIRED to be available on the function ` :date ` :
151107
152- - ` style ` \[ REQUIRED\]
153- - ` full `
108+ - ` fields `
109+ - ` weekday `
110+ - ` day-weekday `
111+ - ` month-day `
112+ - ` month-day-weekday `
113+ - ` year-month-day ` (default)
114+ - ` year-month-day-weekday `
115+ - ` length `
154116 - ` long `
155117 - ` medium ` (default)
156118 - ` short `
157119- _ Date/time override options_
158120
121+ The ` fields ` and ` length ` _ option values_ MUST each be set by a _ literal_ .
122+ If such an _ option value_ is a _ variable_ ,
123+ a _ Bad Option Error_ is emitted and
124+ the _ option_ is ignored when formatting the _ expression_ .
125+
159126If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
160127it can include other option values.
161- Any _ operand_ options matching the ` :datetime ` _ style options_ or _ field options_ are ignored,
162- as is any ` style ` option.
128+ Any _ date/time override options_ of the operand are included in the resolved option values of the _ expression_ ,
129+ with _ options_ on the _ expression_ taking priority over any options of the _ operand_ .
130+ Any _ operand_ options not matching the _ date/time override options_ are ignored.
163131
164132##### Resolved Value
165133
@@ -173,10 +141,12 @@ is used as an _operand_ or an _option value_.
173141#### The ` :time ` function
174142
175143The function ` :time ` is used to format the time portion of date/time values.
144+ Its formatted result will always include the time,
145+ and optionally a timezone.
176146
177147If no options are specified, this function defaults to the following:
178148
179- - ` {$t :time} ` is the same as ` {$t :time style=short } `
149+ - ` {$t :time} ` is the same as ` {$t :time precision=minute } `
180150
181151##### Operands
182152
@@ -187,19 +157,30 @@ All other _operand_ values produce a _Bad Operand_ error.
187157
188158##### Options
189159
190- The function ` :time ` has these _ options _ :
160+ The following _ options _ are REQUIRED to be available on the function ` :time ` :
191161
192- - ` style ` \[ REQUIRED\]
193- - ` full `
162+ - ` precision `
163+ - ` hour `
164+ - ` minute ` (default)
165+ - ` second `
166+ - ` timeZoneStyle `
194167 - ` long `
195- - ` medium `
196- - ` short ` (default)
168+ - ` short `
197169- _ Date/time override options_
198170
171+ If the ` timeZoneStyle ` _ option_ is not included in the _ expression_ ,
172+ its formatted result will not include a timezone indicator.
173+
174+ The ` precision ` and ` timeZoneStyle ` _ option values_ MUST each be set by a _ literal_ .
175+ If such an _ option value_ is a _ variable_ ,
176+ a _ Bad Option Error_ is emitted and
177+ the _ option_ is ignored when formatting the _ expression_ .
178+
199179If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
200180it can include other option values.
201- Any _ operand_ options matching the ` :datetime ` _ style options_ or _ field options_ are ignored,
202- as is any ` style ` option.
181+ Any _ date/time override options_ of the operand are included in the resolved option values of the _ expression_ ,
182+ with _ options_ on the _ expression_ taking priority over any options of the _ operand_ .
183+ Any _ operand_ options not matching the _ date/time override options_ are ignored.
203184
204185##### Resolved Value
205186
0 commit comments