From ca22a2c9d2aec502b1b515b69670eb6804b28b74 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 1 Jul 2024 17:13:40 +0300 Subject: [PATCH 1/8] Define function composition for date/time values --- spec/registry.md | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index b00a1aeab..6025f5cf6 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -796,6 +796,11 @@ output. If both are specified, a _Bad Option_ error MUST be emitted and a _fallback value_ used as the resolved value of the _expression_. +If the _operand_ of the _expression_ is an implementation-defined date/time type, +it can include _style options_, _field options_, or other option values. +These are included in the resolved option values of the _expression_, +with _options_ on the _expression_ taking priority over any option values of the _operand_. + > [!NOTE] > The names of _options_ and their _values_ were derived from the > [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#description) @@ -897,7 +902,15 @@ are encouraged to track development of these options during Tech Preview: - valid [Unicode Number System Identifier](https://cldr-smoke.unicode.org/spec/main/ldml/tr35.html#UnicodeNumberSystemIdentifier) - `timeZone` (default is system default time zone or UTC) - valid identifier per [BCP175](https://www.rfc-editor.org/rfc/rfc6557) - + +#### Composition + +When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ +using an _expression_ with a `:datetime` _annotation_, +its resolved value contains only the implementation-defined datetime value +of the _operand_ of the annotated _expression_, +together with the resolved options values. + ### The `:date` function The function `:date` is used to format the date portion of date/time values. @@ -921,6 +934,19 @@ The function `:date` has these _options_: - `medium` - `short` (default) +If the _operand_ of the _expression_ is an implementation-defined date/time type, +it can include other option values. +Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored, +as is any `style` option. + +#### Composition + +When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ +using an _expression_ with a `:date` _annotation_, +its resolved value contains only the implementation-defined date/time value +of the _operand_ of the annotated _expression_ (with no time value), +together with the resolved options values. + ### The `:time` function The function `:time` is used to format the time portion of date/time values. @@ -944,6 +970,21 @@ The function `:time` has these _options_: - `medium` - `short` (default) +If the _operand_ of the _expression_ is an implementation-defined date/time type, +it can include other option values. +Any _operand_ option values matching the `:datetime` _style options_ or _field options_ are ignored, +as is any `style` option. + +#### Composition + +When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ +using an _expression_ with a `:time` _annotation_, +its resolved value contains only the implementation-defined date/time value +of the _operand_ of the annotated _expression_ (with no date value), +together with the resolved options values. + +Using a `:time` annotated value as the _operand_ of `:datetime` or `:date` +produces a _Bad Operand_ error as it contains no date value. ### Date and Time Operands @@ -993,5 +1034,3 @@ For more information, see [Working with Timezones](https://w3c.github.io/timezon > The form of these serializations is known and is a de facto standard. > Support for these extensions is expected to be required in the post-tech preview. > See: https://datatracker.ietf.org/doc/draft-ietf-sedate-datetime-extended/ - - From 30d022b0e802d4d72cac03e2de58f84d4fae8591 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 8 Jul 2024 21:11:11 +0300 Subject: [PATCH 2/8] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stanisław Małolepszy --- spec/registry.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 6025f5cf6..2672f034d 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -905,8 +905,8 @@ are encouraged to track development of these options during Tech Preview: #### Composition -When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ -using an _expression_ with a `:datetime` _annotation_, +When an _operand_ or an _option_ value uses a _variable_ annotated, +directly or indirectly, by a `:datetime` _annotation_, its resolved value contains only the implementation-defined datetime value of the _operand_ of the annotated _expression_, together with the resolved options values. @@ -941,8 +941,8 @@ as is any `style` option. #### Composition -When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ -using an _expression_ with a `:date` _annotation_, +When an _operand_ or an _option_ value uses a _variable_ annotated, +directly or indirectly, by a `:date` _annotation_, its resolved value contains only the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no time value), together with the resolved options values. @@ -977,8 +977,8 @@ as is any `style` option. #### Composition -When an _operand_ or an _option_ value uses a _variable_ with a _declaration_ -using an _expression_ with a `:time` _annotation_, +When an _operand_ or an _option_ value uses a _variable_ annotated, +directly or indirectly, by a `:time` _annotation_, its resolved value contains only the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no date value), together with the resolved options values. From 0cc8eef32ab2e37abca99345e0342d5229fc4290 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jul 2024 10:57:24 +0300 Subject: [PATCH 3/8] Drop the "only" --- spec/registry.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 2672f034d..bc04c1f43 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -907,7 +907,7 @@ are encouraged to track development of these options during Tech Preview: When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:datetime` _annotation_, -its resolved value contains only the implementation-defined datetime value +its resolved value contains the implementation-defined datetime value of the _operand_ of the annotated _expression_, together with the resolved options values. @@ -943,7 +943,7 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:date` _annotation_, -its resolved value contains only the implementation-defined date/time value +its resolved value contains the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no time value), together with the resolved options values. @@ -979,7 +979,7 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:time` _annotation_, -its resolved value contains only the implementation-defined date/time value +its resolved value contains the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no date value), together with the resolved options values. From dc776e1c6fb9d8d6817a50e59d7e86efe6c1b0f9 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 15 Jul 2024 19:18:37 +0300 Subject: [PATCH 4/8] Update spec/registry.md --- spec/registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index bc04c1f43..65c55a2d1 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -907,7 +907,7 @@ are encouraged to track development of these options during Tech Preview: When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:datetime` _annotation_, -its resolved value contains the implementation-defined datetime value +its resolved value contains an implementation-defined date/time value of the _operand_ of the annotated _expression_, together with the resolved options values. From 22420350855e3b4dafc21fcccdf125379ec5671b Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 7 Oct 2024 09:27:18 -0700 Subject: [PATCH 5/8] Update spec/registry.md Co-authored-by: Eemeli Aro --- spec/registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index 65c55a2d1..17e9574ea 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -907,7 +907,7 @@ are encouraged to track development of these options during Tech Preview: When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:datetime` _annotation_, -its resolved value contains an implementation-defined date/time value +its _resolved value_ contains an implementation-defined date/time value of the _operand_ of the annotated _expression_, together with the resolved options values. From 3d335fe9d1c21faa1e012718ac37850c96cb5414 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 7 Oct 2024 09:27:35 -0700 Subject: [PATCH 6/8] Update spec/registry.md Co-authored-by: Eemeli Aro --- spec/registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index 17e9574ea..788bdccfb 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -979,7 +979,7 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:time` _annotation_, -its resolved value contains the implementation-defined date/time value +its _resolved value_ contains the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no date value), together with the resolved options values. From 05040e3bd37b9bb13dc2b0e19d74216ccea93d55 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 7 Oct 2024 09:27:53 -0700 Subject: [PATCH 7/8] Update spec/registry.md Co-authored-by: Eemeli Aro --- spec/registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index 788bdccfb..b294dee33 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -943,7 +943,7 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:date` _annotation_, -its resolved value contains the implementation-defined date/time value +its _resolved value_ contains the implementation-defined date/time value of the _operand_ of the annotated _expression_ (with no time value), together with the resolved options values. From 54fa33ed83fac96a644b69abcd6a651a6c340a42 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Thu, 10 Oct 2024 22:28:12 +0300 Subject: [PATCH 8/8] Make :date and :time composition implementation-defined --- spec/registry.md | 15 ++++++--------- test/tests/functions/date.json | 4 ++-- test/tests/functions/time.json | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 77f8758be..44c5dd5b6 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -742,9 +742,9 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:date` _annotation_, -its _resolved value_ contains the implementation-defined date/time value -of the _operand_ of the annotated _expression_ (with no time value), -together with the resolved options values. +its _resolved value_ is implementation-defined. +An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate) +when this happens. ### The `:time` function @@ -778,12 +778,9 @@ as is any `style` option. When an _operand_ or an _option_ value uses a _variable_ annotated, directly or indirectly, by a `:time` _annotation_, -its _resolved value_ contains the implementation-defined date/time value -of the _operand_ of the annotated _expression_ (with no date value), -together with the resolved options values. - -Using a `:time` annotated value as the _operand_ of `:datetime` or `:date` -produces a _Bad Operand_ error as it contains no date value. +its _resolved value_ is implementation-defined. +An implementation MAY emit a _Bad Operand_ or _Bad Option_ error (as appropriate) +when this happens. ### Date and Time Operands diff --git a/test/tests/functions/date.json b/test/tests/functions/date.json index 494ca8d23..c426173d6 100644 --- a/test/tests/functions/date.json +++ b/test/tests/functions/date.json @@ -35,10 +35,10 @@ "src": "{|2006-01-02| :date style=long}" }, { - "src": ".local $d = {|2006-01-02| :date style=long} {{{$d :date}}}" + "src": ".local $d = {|2006-01-02| :date style=long} {{{$d}}}" }, { - "src": ".local $t = {|2006-01-02T15:04:06| :time} {{{$t :date}}}" + "src": ".local $d = {|2006-01-02| :datetime dateStyle=long timeStyle=long} {{{$d :date}}}" } ] } diff --git a/test/tests/functions/time.json b/test/tests/functions/time.json index 416d18a3e..f4ec1b2d5 100644 --- a/test/tests/functions/time.json +++ b/test/tests/functions/time.json @@ -32,10 +32,10 @@ "src": "{|2006-01-02T15:04:06| :time style=medium}" }, { - "src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t :time}}}" + "src": ".local $t = {|2006-01-02T15:04:06| :time style=medium} {{{$t}}}" }, { - "src": ".local $d = {|2006-01-02T15:04:06| :date} {{{$d :time}}}" + "src": ".local $t = {|2006-01-02T15:04:06| :datetime dateStyle=long timeStyle=long} {{{$t :time}}}" } ] }