Skip to content

Commit 2334e16

Browse files
eemelistasmaphillips
authored
Define function composition for date/time values (#814)
* Define function composition for date/time values * Apply suggestions from code review Co-authored-by: Stanisław Małolepszy <[email protected]> * Drop the "only" * Update spec/registry.md * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Make :date and :time composition implementation-defined --------- Co-authored-by: Stanisław Małolepszy <[email protected]> Co-authored-by: Addison Phillips <[email protected]>
1 parent 9e595f6 commit 2334e16

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

spec/registry.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ output.
593593
If both are specified, a _Bad Option_ error MUST be emitted
594594
and a _fallback value_ used as the _resolved value_ of the _expression_.
595595
596+
If the _operand_ of the _expression_ is an implementation-defined date/time type,
597+
it can include _style options_, _field options_, or other option values.
598+
These are included in the resolved option values of the _expression_,
599+
with _options_ on the _expression_ taking priority over any option values of the _operand_.
600+
596601
> [!NOTE]
597602
> The names of _options_ and their _values_ were derived from the
598603
> [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#description)
@@ -692,7 +697,15 @@ are encouraged to track development of these options during Tech Preview:
692697
- valid [Unicode Number System Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeNumberSystemIdentifier)
693698
- `timeZone` (default is system default time zone or UTC)
694699
- valid identifier per [BCP175](https://www.rfc-editor.org/rfc/rfc6557)
695-
700+
701+
#### Composition
702+
703+
When an _operand_ or an _option_ value uses a _variable_ annotated,
704+
directly or indirectly, by a `:datetime` _annotation_,
705+
its _resolved value_ contains an implementation-defined date/time value
706+
of the _operand_ of the annotated _expression_,
707+
together with the resolved options values.
708+
696709
### The `:date` function
697710
698711
The function `:date` is used to format the date portion of date/time values.
@@ -716,6 +729,19 @@ The function `:date` has these _options_:
716729
- `medium` (default)
717730
- `short`
718731
732+
If the _operand_ of the _expression_ is an implementation-defined date/time type,
733+
it can include other option values.
734+
Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored,
735+
as is any `style` option.
736+
737+
#### Composition
738+
739+
When an _operand_ or an _option_ value uses a _variable_ annotated,
740+
directly or indirectly, by a `:date` _annotation_,
741+
its _resolved value_ is implementation-defined.
742+
An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate)
743+
when this happens.
744+
719745
### The `:time` function
720746
721747
The function `:time` is used to format the time portion of date/time values.
@@ -739,6 +765,18 @@ The function `:time` has these _options_:
739765
- `medium`
740766
- `short` (default)
741767
768+
If the _operand_ of the _expression_ is an implementation-defined date/time type,
769+
it can include other option values.
770+
Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored,
771+
as is any `style` option.
772+
773+
#### Composition
774+
775+
When an _operand_ or an _option_ value uses a _variable_ annotated,
776+
directly or indirectly, by a `:time` _annotation_,
777+
its _resolved value_ is implementation-defined.
778+
An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate)
779+
when this happens.
742780
743781
### Date and Time Operands
744782
@@ -788,5 +826,3 @@ For more information, see [Working with Timezones](https://w3c.github.io/timezon
788826
> The form of these serializations is known and is a de facto standard.
789827
> Support for these extensions is expected to be required in the post-tech preview.
790828
> See: https://datatracker.ietf.org/doc/draft-ietf-sedate-datetime-extended/
791-
792-

test/tests/functions/date.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"src": "{|2006-01-02| :date style=long}"
3636
},
3737
{
38-
"src": ".local $d = {|2006-01-02| :date style=long} {{{$d :date}}}"
38+
"src": ".local $d = {|2006-01-02| :date style=long} {{{$d}}}"
3939
},
4040
{
41-
"src": ".local $t = {|2006-01-02T15:04:06| :time} {{{$t :date}}}"
41+
"src": ".local $d = {|2006-01-02| :datetime dateStyle=long timeStyle=long} {{{$d :date}}}"
4242
}
4343
]
4444
}

test/tests/functions/time.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"src": "{|2006-01-02T15:04:06| :time style=medium}"
3333
},
3434
{
35-
"src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t :time}}}"
35+
"src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t}}}"
3636
},
3737
{
38-
"src": ".local $d = {|2006-01-02T15:04:06| :date} {{{$d :time}}}"
38+
"src": ".local $t = {|2006-01-02T15:04:06| :datetime dateStyle=long timeStyle=long} {{{$t :time}}}"
3939
}
4040
]
4141
}

0 commit comments

Comments
 (0)