Skip to content

Commit acc5969

Browse files
eemeliaphillips
andauthored
Define _option value_ and _digit size option_ (#1039)
* Define _option value_ and _digit size option_ * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent ac3d8d6 commit acc5969

File tree

9 files changed

+140
-144
lines changed

9 files changed

+140
-144
lines changed

spec/errors.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ for that specific _function_.
347347
#### Bad Option
348348
349349
A **_<dfn>Bad Option</dfn>_** error is an error that occurs when there is
350-
an implementation-defined error with an _option_ or its value.
350+
an implementation-defined error with an _option_ or an _option value_.
351351
These might include:
352352
- A required _option_ is missing.
353353
- Mutually exclusive _options_ are supplied.
354-
- An _option_ value provided to a _function_ during _function resolution_
354+
- An _option value_ provided to a _function_ during _function resolution_
355355
does not match one of the implementation-defined types or values for that _function_;
356-
or in which the literal _option_ value does not have the required format
356+
or in which the _string value_ of an _option_ does not have the required format
357357
and thus cannot be processed into one of the expected
358358
implementation-defined types for that specific _function_.
359359
@@ -386,5 +386,5 @@ does not match the expected implementation-defined format.
386386
#### Unsupported Operation
387387
388388
A **_<dfn>Unsupported Operation</dfn>_** error is an implementation-specific error
389-
that occurs when a given _option_, _option_ value, _operand_ value, or some combination
389+
that occurs when a given _option_, _option value_, _operand_, or some combination
390390
of these are incompatible or not supported by a given _function_ or its _function handler_.

spec/formatting.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,12 @@ as well as a flag to indicate whether
137137
its formatted representation requires isolation
138138
from the surrounding text.
139139
140-
For each _option_ value, the _resolved value_ MUST indicate if the value
140+
For each _option value_, the _resolved value_ MUST indicate if the value
141141
was directly set with a _literal_, as opposed to being resolved from a _variable_.
142142
This is to allow _functions handlers_ to require specific _options_ to be set using _literals_.
143143
144144
> For example, the _default functions_ `:number` and `:integer` require that the _option_
145-
> `select` be set with a _literal_ (`plural`, `ordinal`, or `exact`).
146-
> Allowing a _variable_ in this _option_ would produce a _message_ that
147-
> is impossible to translate because the set of _keys_ is tied to the _selector_ chosen.
148-
149-
> [!NOTE]
150-
> Such information is irrelevant for _resolved values_ not used as the value of an _option_.
145+
> `select` be set with a _literal_ _option value_ (`plural`, `ordinal`, or `exact`).
151146
152147
The form that _resolved values_ take is implementation-dependent,
153148
and different implementations MAY choose to perform different levels of resolution.
@@ -177,7 +172,7 @@ and different implementations MAY choose to perform different levels of resoluti
177172
> calling the `selectKeys(keys)` method of its _resolved value_
178173
> did not emit an error.
179174
> - Using a _variable_, the _resolved value_ of an _expression_
180-
> could be used as an _operand_ or _option_ value if
175+
> could be used as an _operand_ or _option value_ if
181176
> calling the `getValue()` method of its _resolved value_ did not emit an error.
182177
> In this use case, the `resolvedOptions()` method could also
183178
> provide a set of option values that could be taken into account by the called function.
@@ -246,8 +241,7 @@ Its _resolved value_ is defined by _literal resolution_.
246241
the character sequence of the _text_ or _literal_
247242
after any character escape has been converted to the escaped character.
248243
249-
When a _literal_ is used as an _operand_
250-
or on the right-hand side of an _option_,
244+
When a _literal_ is used as an _operand_ or as an _option value_,
251245
the formatting function MUST treat its _resolved value_ the same
252246
whether its value was originally a _quoted literal_ or an _unquoted literal_.
253247
@@ -329,15 +323,15 @@ the following steps are taken:
329323
- The resolved mapping of _options_.
330324
- If the _expression_ includes an _operand_, its _resolved value_.
331325
332-
The form that resolved _operand_ and _option_ values take is implementation-defined.
326+
The form that resolved _operand_ and _option values_ take is implementation-defined.
333327
334328
An implementation MAY pass additional arguments to the _function handler_,
335329
as long as reasonable precautions are taken to keep the function interface
336330
simple and minimal, and avoid introducing potential security vulnerabilities.
337331
338332
6. If the call succeeds,
339333
resolve the value of the _expression_ as the result of that function call.
340-
The value MUST NOT be marked as a literal option value.
334+
The value MUST NOT be marked as a _literal_ _option value_.
341335
342336
If the call fails or does not return a valid value,
343337
emit the appropriate _Message Function Error_ for the failure.
@@ -363,7 +357,7 @@ An implementation MAY allow custom functions to be defined by users.
363357
Implementations that provide a means for defining custom functions
364358
MUST provide a means for _function handlers_
365359
to return _resolved values_ that contain enough information
366-
to be used as _operands_ or _option_ values in subsequent _expressions_.
360+
to be used as _operands_ or _option values_ in subsequent _expressions_.
367361
368362
The _resolved value_ returned by a _function handler_
369363
MAY be different from the value of the _operand_ of the _function_.
@@ -399,12 +393,12 @@ For each _option_:
399393
1. Let `res` be a new empty mapping.
400394
1. For each _option_:
401395
1. Let `id` be the string value of the _identifier_ of the _option_.
402-
1. Let `rv` be the _resolved value_ of the _option_ value.
396+
1. Let `rv` be the _resolved value_ of the _option value_.
403397
1. If `rv` is a _fallback value_:
404398
1. If supported, emit a _Bad Option_ error.
405399
1. Else:
406-
1. If the _option_ value consists of a _literal_:
407-
1. Mark `rv` as a literal option value.
400+
1. If the _option value_ consists of a _literal_:
401+
1. Mark `rv` as a _literal_ _option value_.
408402
1. Set `res[id]` to be `rv`.
409403
1. Return `res`.
410404
@@ -428,7 +422,7 @@ The _resolved value_ of _markup_ includes the following fields:
428422
429423
- The type of the markup: open, standalone, or close
430424
- The _identifier_ of the _markup_
431-
- The resolved _options_ values after _option resolution_.
425+
- The resolved mapping of _options_ after _option resolution_.
432426
433427
If the resolved mapping of _options_ includes any _`u:` options_
434428
supported by the implementation, process them as specified.
@@ -440,8 +434,8 @@ The resolution of _markup_ MUST always succeed.
440434
441435
A **_<dfn>fallback value</dfn>_** is the _resolved value_ for
442436
an _expression_ or _variable_ when that _expression_ or _variable_ fails to resolve.
443-
It contains a string representation that is used for its formatting,
444-
and no option values.
437+
It contains a string representation that is used for its formatting.
438+
All _options_ are removed.
445439
446440
The _resolved value_ of _text_, _literal_, and _markup_ MUST NOT be a _fallback value_.
447441
@@ -453,7 +447,7 @@ An _expression_ fails to resolve when:
453447
454448
- A _variable_ used as its _operand_ resolves to a _fallback value_.
455449
Note that an _expression_ does not necessarily fail to resolve
456-
if an _option_ resolves with a _fallback value_.
450+
if an _option value_ resolves with a _fallback value_.
457451
- No _function handler_ is found for a _function_ _identifier_.
458452
- Calling a _function handler_ fails or does not return a valid value.
459453

spec/functions/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ emit an _Unknown Function_ error for that _function_'s _identifier_.
2525
To _accept_ an _option_ means that a _function handler_ MUST NOT
2626
emit a _Bad Option_ error for that _option_'s _identifier_ when used with the _function_
2727
it is defined for
28-
and MUST NOT emit a _Bad Option_ error for any of the _option_ values
28+
and MUST NOT emit a _Bad Option_ error for any of the _option values_
2929
defined for that _option_.
3030
Accepting a _function_ or its _options_ does not mean that a particular output is produced.
3131
Implementations MAY emit an _Unsupported Operation_ error for _options_
32-
or _option_ values that they cannot support.
32+
or _option values_ that they cannot support.
3333

3434
_Functions_ can define _options_.
3535
An _option_ can be REQUIRED or RECOMMENDED.
@@ -54,11 +54,11 @@ by any version of this specification for _default functions_.
5454
Such _options_ MUST use an implementation-specific _namespace_.
5555

5656
Implementations MAY _accept_, for _options_ defined in this specification,
57-
_option_ values which are not defined in this specification.
57+
_option values_ which are not defined in this specification.
5858
However, such values might become defined with a different meaning in the future,
5959
including with a different, incompatible name
6060
or using an incompatible value space.
61-
Supporting implementation-specific _option_ values for _default functions_ is NOT RECOMMENDED.
61+
Supporting implementation-specific _option values_ for _default functions_ is NOT RECOMMENDED.
6262

6363
Implementations MAY _accept_, for _operands_ or _options_ defined in this specification,
6464
values with implementation-defined types.
@@ -71,11 +71,11 @@ Such values can be useful to users in cases where local usage and support exists
7171
> - A Java implementation might _accept_ a `java.time.chrono.Chronology` object
7272
> as a value for the _date/time override option_ `calendar`
7373
74-
Future versions of this specification MAY define additional _options_ and _option_ values,
74+
Future versions of this specification MAY define additional _options_ and _option values_,
7575
subject to the rules in the [Stability Policy](#stability-policy),
7676
for _functions_ found in this specification.
7777
As implementations are permitted to ignore _options_ that they do not support,
78-
it is possible to write _messages_ using _options_ not defined below
78+
it is possible to write _messages_ using _options_ not defined here
7979
which currently format with no error, but which could produce errors
8080
when formatted with a later edition of this specification.
8181
Therefore, using _options_ not explicitly defined here is NOT RECOMMENDED.

spec/functions/datetime.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ a _Bad Option_ error is emitted
4545
and a _fallback value_ used as the _resolved value_ of the _expression_.
4646

4747
If the _operand_ of the _expression_ is an implementation-defined date/time type,
48-
it can include _style options_, _field options_, or other option values.
48+
it can include _style options_, _field options_, or other _options_.
4949
These are included in the resolved option values of the _expression_,
50-
with _options_ on the _expression_ taking priority over any option values of the _operand_.
50+
with _options_ on the _expression_ taking priority over any options of the _operand_.
5151

5252
> [!NOTE]
53-
> The names of _options_ and their _values_ were derived from the
53+
> The names of _options_ and their _option values_ were derived from the
5454
> [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#description)
5555
> in JavaScript's `Intl.DateTimeFormat`.
5656
5757
###### Style Options
5858

5959
**_<dfn>Style options</dfn>_** pertain to the overall styling or appearance of the formatted output.
6060

61-
The function `:datetime` has these _style options_.
61+
The following _style options_ are REQUIRED to be available on the function `:datetime`:
6262

6363
- `dateStyle`
6464
- `full`
@@ -80,7 +80,7 @@ and what format to use for that field.
8080
> _Field options_ do not have default values because they are only to be used
8181
> to compose the formatter.
8282
83-
The function `:datetime` has the following _field options_:
83+
The following _field options_ are REQUIRED to be available on the function `:datetime`:
8484

8585
- `weekday`
8686
- `long`
@@ -149,7 +149,7 @@ All other _operand_ values produce a _Bad Operand_ error.
149149

150150
The function `:date` has these _options_:
151151

152-
- `style`
152+
- `style` \[REQUIRED\]
153153
- `full`
154154
- `long`
155155
- `medium` (default)
@@ -158,7 +158,7 @@ The function `:date` has these _options_:
158158

159159
If the _operand_ of the _expression_ is an implementation-defined date/time type,
160160
it can include other option values.
161-
Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored,
161+
Any _operand_ options matching the `:datetime` _style options_ or _field options_ are ignored,
162162
as is any `style` option.
163163

164164
##### Resolved Value
@@ -168,7 +168,7 @@ is implementation-defined.
168168

169169
An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate)
170170
when a _variable_ annotated directly or indirectly by a `:date` _annotation_
171-
is used as an _operand_ or an _option_ value.
171+
is used as an _operand_ or an _option value_.
172172

173173
#### The `:time` function
174174

@@ -189,7 +189,7 @@ All other _operand_ values produce a _Bad Operand_ error.
189189

190190
The function `:time` has these _options_:
191191

192-
- `style`
192+
- `style` \[REQUIRED\]
193193
- `full`
194194
- `long`
195195
- `medium`
@@ -198,7 +198,7 @@ The function `:time` has these _options_:
198198

199199
If the _operand_ of the _expression_ is an implementation-defined date/time type,
200200
it can include other option values.
201-
Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored,
201+
Any _operand_ options matching the `:datetime` _style options_ or _field options_ are ignored,
202202
as is any `style` option.
203203

204204
##### Resolved Value
@@ -208,7 +208,7 @@ is implementation-defined.
208208

209209
An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate)
210210
when a _variable_ annotated directly or indirectly by a `:time` _annotation_
211-
is used as an _operand_ or an _option_ value.
211+
is used as an _operand_ or an _option value_.
212212

213213
#### Date and Time Operands
214214

@@ -271,20 +271,7 @@ or embedded in an implementation-defined date/time _operand_ value.
271271
> These _options_ do not have default values because they are only to be used
272272
> as overrides for locale-and-value dependent implementation-defined defaults.
273273
274-
The following _option_ and its values are REQUIRED to be available on
275-
the functions `:datetime` and `:time`:
276-
277-
- `hour12`
278-
- `true`
279-
- `false`
280-
281-
The following _option_ and its values are RECOMMENDED to be available on
282-
the functions `:datetime`, `:date`, and `:time`.
283-
284-
- `calendar`
285-
- valid [Unicode Calendar Identifier](https://unicode.org/reports/tr35/tr35.html#UnicodeCalendarIdentifier)
286-
287-
The following _option_ and its values are REQUIRED to be available on
274+
The following _option_ is REQUIRED to be available on
288275
the functions `:datetime`, `:date`, and `:time`.
289276
290277
- `timeZone`
@@ -300,3 +287,16 @@ the functions `:datetime`, `:date`, and `:time`.
300287
> into a [floating](https://www.w3.org/TR/timezone/#floating) time value
301288
> (sometimes called a _plain_ or _local_ time value) by removing
302289
> the association with a specific time zone.
290+
291+
The following _option_ is REQUIRED to be available on
292+
the functions `:datetime` and `:time`:
293+
294+
- `hour12`
295+
- `true`
296+
- `false`
297+
298+
The following _option_ is RECOMMENDED to be available on
299+
the functions `:datetime`, `:date`, and `:time`.
300+
301+
- `calendar`
302+
- valid [Unicode Calendar Identifier](https://unicode.org/reports/tr35/tr35.html#UnicodeCalendarIdentifier)

0 commit comments

Comments
 (0)