@@ -5,24 +5,31 @@ This subsection describes the _functions_ and _options_ for date/time formatting
5
5
> [ !IMPORTANT]
6
6
> The _ functions_ in this section have a status of ** Draft** .
7
7
> 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.
8
11
9
12
> [ !NOTE]
10
13
> Selection based on date/time types is not required by this release of MessageFormat.
11
14
> Use care when defining implementation-specific _ selectors_ based on date/time types.
12
15
> The types of queries found in implementations such as ` java.time.TemporalAccessor `
13
16
> are complex and user expectations might be inconsistent with good I18N practices.
14
17
18
+ [ Semantic Skeletons ] : https://www.unicode.org/reports/tr35/tr35-75/tr35-dates.html#Semantic_Skeletons
19
+
15
20
#### The ` :datetime ` function
16
21
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.
19
25
20
26
If no options are specified, this function defaults to the following:
21
27
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} `
23
30
24
31
> [ !NOTE]
25
- > The default formatting behavior of ` :datetime ` is inconsistent with ` Intl.DateTimeFormat `
32
+ > The formatting behavior of ` :datetime ` is inconsistent with ` Intl.DateTimeFormat `
26
33
> in JavaScript and with ` {d,date} ` in ICU MessageFormat 1.0.
27
34
> This is because, unlike those implementations, ` :datetime ` is distinct from ` :date ` and ` :time ` .
28
35
@@ -35,93 +42,42 @@ All other _operand_ values produce a _Bad Operand_ error.
35
42
36
43
##### Options
37
44
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 ` :
58
46
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 `
65
55
- ` long `
66
- - ` medium `
56
+ - ` medium ` (default)
67
57
- ` short `
68
- - ` timeStyle `
69
- - ` full `
58
+ - ` timePrecision `
59
+ - ` hour `
60
+ - ` minute ` (default)
61
+ - ` second `
62
+ - ` timeZoneStyle `
70
63
- ` long `
71
- - ` medium `
72
64
- ` short `
65
+ - _ Date/time override options_
73
66
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.
82
69
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_ .
84
75
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.
125
81
126
82
##### Resolved Value
127
83
@@ -136,7 +92,7 @@ The function `:date` is used to format the date portion of date/time values.
136
92
137
93
If no options are specified, this function defaults to the following:
138
94
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} `
140
96
141
97
##### Operands
142
98
@@ -147,19 +103,31 @@ All other _operand_ values produce a _Bad Operand_ error.
147
103
148
104
##### Options
149
105
150
- The function ` :date ` has these _ options _ :
106
+ The following _ options _ are REQUIRED to be available on the function ` :date ` :
151
107
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 `
154
116
- ` long `
155
117
- ` medium ` (default)
156
118
- ` short `
157
119
- _ Date/time override options_
158
120
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
+
159
126
If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
160
127
it 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.
163
131
164
132
##### Resolved Value
165
133
@@ -173,10 +141,12 @@ is used as an _operand_ or an _option value_.
173
141
#### The ` :time ` function
174
142
175
143
The 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.
176
146
177
147
If no options are specified, this function defaults to the following:
178
148
179
- - ` {$t :time} ` is the same as ` {$t :time style=short } `
149
+ - ` {$t :time} ` is the same as ` {$t :time precision=minute } `
180
150
181
151
##### Operands
182
152
@@ -187,19 +157,30 @@ All other _operand_ values produce a _Bad Operand_ error.
187
157
188
158
##### Options
189
159
190
- The function ` :time ` has these _ options _ :
160
+ The following _ options _ are REQUIRED to be available on the function ` :time ` :
191
161
192
- - ` style ` \[ REQUIRED\]
193
- - ` full `
162
+ - ` precision `
163
+ - ` hour `
164
+ - ` minute ` (default)
165
+ - ` second `
166
+ - ` timeZoneStyle `
194
167
- ` long `
195
- - ` medium `
196
- - ` short ` (default)
168
+ - ` short `
197
169
- _ Date/time override options_
198
170
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
+
199
179
If the _ operand_ of the _ expression_ is an implementation-defined date/time type,
200
180
it 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.
203
184
204
185
##### Resolved Value
205
186
0 commit comments