Skip to content

Commit 4d120e5

Browse files
aphillipssffceemelistasm
authored
Implement changes to date/time functions (#648)
* Implement changes to date/time functions This is per the 2024-02-14 teleconference. * Move `timezoneName` out of `:date`; clarify defaults or lack thereof Consistent with `:number` doc * change error to Operand Mismatch Error * Update exploration/default-registry-and-mf1-compatibility.md Co-authored-by: Shane F. Carr <[email protected]> * Update exploration/default-registry-and-mf1-compatibility.md Co-authored-by: Eemeli Aro <[email protected]> * Apply suggestions from code review Co-authored-by: Eemeli Aro <[email protected]> * Update exploration/default-registry-and-mf1-compatibility.md Co-authored-by: Stanisław Małolepszy <[email protected]> * Update exploration/default-registry-and-mf1-compatibility.md Co-authored-by: Eemeli Aro <[email protected]> * Update exploration/default-registry-and-mf1-compatibility.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Shane F. Carr <[email protected]> Co-authored-by: Eemeli Aro <[email protected]> Co-authored-by: Stanisław Małolepszy <[email protected]>
1 parent 87a5910 commit 4d120e5

File tree

1 file changed

+49
-26
lines changed

1 file changed

+49
-26
lines changed

exploration/default-registry-and-mf1-compatibility.md

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Therefore, addition to this list requires a higher level of rigor.
3333

3434
### Numbers
3535

36+
> [!IMPORTANT]
37+
> This section is replaced by the design for number selection
38+
3639
Function name: `:number`
3740

3841
Aliases:
@@ -86,6 +89,11 @@ If no options are specified, each of the functions defaults to the following:
8689
> Pattern selection based on date/time values is a complex topic and no support for this
8790
> is required in this release.
8891
92+
> [!NOTE]
93+
> The default formatting behavior of `:datetime` is inconsistent with `Intl.DateTimeFormat`
94+
> in JavaScript and with `{d,date}` in MessageFormat v1.
95+
> This is because, unlike those implementations, `:datetime` is distinct from `:date` and `:time`.
96+
8997
#### Operands
9098

9199
The _operand_ of a date/time function is either
@@ -109,7 +117,7 @@ For more information, see [Working with Timezones](https://w3c.github.io/timezon
109117
> The [ABNF](/spec/message.abnf) and [syntax](/spec/syntax.md) of MFv2
110118
> do not formally define date/time literals.
111119
> This means that a _message_ can be syntactically valid but produce
112-
> runtime errors due to what amounts to a "type mismatch".
120+
> an _Operand Mismatch Error_ at runtime.
113121
114122
> [!NOTE]
115123
> String values passed as variables in the _formatting context_'s
@@ -133,20 +141,15 @@ For more information, see [Working with Timezones](https://w3c.github.io/timezon
133141
134142
#### Options
135143
136-
All date/time functions support the following options, which
137-
provide high-level control over date/time formats:
138-
- `calendar` (default is locale-specific)
139-
- valid [Unicode Calendar Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeCalendarIdentifier)
140-
- `numberingSystem` (default is locale-specific)
141-
- valid [Unicode Number System Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeNumberSystemIdentifier)
142-
- `timeZone` (default is system default time zone or UTC)
143-
- valid identifier per [BCP175](https://www.rfc-editor.org/rfc/rfc6557)
144-
145-
In addition to the above high-level options, a function can use either the appropriate
146-
_style_ options for that function
144+
A function can use either the appropriate _style_ options for that function
147145
or can use a collection of _field options_ (but not both) to control the formatted
148146
output.
149147
148+
If both are specified, an _Invalid Expression_ error MUST be emitted
149+
and a _fallback value_ used as the resolved value of the _expression_.
150+
151+
##### Style Options
152+
150153
The function `:datetime` has these function-specific _style_ options.
151154
- `dateStyle`
152155
- `full`
@@ -164,27 +167,28 @@ The function `:date` has these function-specific _style_ options:
164167
- `full`
165168
- `long`
166169
- `medium`
167-
- `short`
170+
- `short` (default)
168171
169172
The function `:time` has these function-specific _style_ options:
170173
- `style`
171174
- `full`
172175
- `long`
173176
- `medium`
174-
- `short`
177+
- `short` (default)
175178
176-
The _field_ options are defined as follows:
179+
##### Field Options
177180
178-
All functions have the following option:
179-
- `timeZoneName`
180-
- `long`
181-
- `short`
182-
- `shortOffset`
183-
- `longOffset`
184-
- `shortGeneric`
185-
- `longGeneric`
181+
Field options describe which fields to include in the formatted output
182+
and what format to use for that field.
183+
Only those fields specified in the _annotation_ appear in the formatted output.
184+
185+
> [!NOTE]
186+
> Field options do not have default values because they are only to be used
187+
> to compose the formatter.
186188
187-
The functions `:datetime` and `:date` have the following options:
189+
The _field_ options are defined as follows:
190+
191+
The function `:datetime` has the following options:
188192
- `weekday`
189193
- `long`
190194
- `short`
@@ -205,8 +209,6 @@ The functions `:datetime` and `:date` have the following options:
205209
- `day`
206210
- `numeric`
207211
- `2-digit`
208-
209-
The functions `:datetime` and `:time` have the following options:
210212
- `hour`
211213
- `numeric`
212214
- `2-digit`
@@ -225,6 +227,27 @@ The functions `:datetime` and `:time` have the following options:
225227
- `h12`
226228
- `h23`
227229
- `h24`
230+
- `timeZoneName`
231+
- `long`
232+
- `short`
233+
- `shortOffset`
234+
- `longOffset`
235+
- `shortGeneric`
236+
- `longGeneric`
237+
238+
> [!NOTE]
239+
> The following options do not have default values because they are only to be used
240+
> as overrides for locale-and-value dependent implementation-defined defaults.
241+
242+
The followind date/time options are *not* part of the default registry.
243+
Implementations SHOULD avoid creating options that conflict with these, but
244+
are encouraged to track development of these options during Tech Preview:
245+
- `calendar` (default is locale-specific)
246+
- valid [Unicode Calendar Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeCalendarIdentifier)
247+
- `numberingSystem` (default is locale-specific)
248+
- valid [Unicode Number System Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeNumberSystemIdentifier)
249+
- `timeZone` (default is system default time zone or UTC)
250+
- valid identifier per [BCP175](https://www.rfc-editor.org/rfc/rfc6557)
228251
229252
230253
#### Selection

0 commit comments

Comments
 (0)