From d8e8529e8dc0d9d94437449d5f691a0219c0259e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 15 Aug 2022 16:33:05 -0700 Subject: [PATCH] Temporal: Add tests for PlainTime string disambiguation with time zone This implements the normative change in https://github.com/tc39/proposal-temporal/pull/2284 which reached consensus at the July 2022 TC39 meeting. It adds tests that ensure strings like HHMM-UU[TZ] and HHMMSS[TZ] do not require a disambiguating T separator, even if HHMM-UU and HHMMSS would by themselves. --- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- ...-designator-required-for-disambiguation.js | 28 +++++++++++-------- 9 files changed, 153 insertions(+), 99 deletions(-) diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-designator-required-for-disambiguation.js index 797192c779..2569d45083 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-designator-required-for-disambiguation.js index 62877675b8..e515710ffc 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js index 62b61c51ee..595cf3b760 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.withPlainTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-time-designator-required-for-disambiguation.js index a3cbbf96ee..567a967dc9 100644 --- a/test/built-ins/Temporal/PlainTime/compare/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-time-designator-required-for-disambiguation.js @@ -49,17 +49,23 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => { Temporal.PlainTime.compare(arg, midnight); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation.js index 20dcb43eb4..80ef0d1ce0 100644 --- a/test/built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation.js @@ -36,16 +36,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => Temporal.PlainTime.from(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-designator-required-for-disambiguation.js index b5efb776c3..ea822acf04 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-designator-required-for-disambiguation.js index 2e9c362004..55831287f8 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-designator-required-for-disambiguation.js index 3f11bf7f3b..e8fda186c9 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.until(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js index a2b10a2b5d..ee5da88b01 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation.js @@ -38,16 +38,22 @@ ambiguousStrings.forEach((string) => { // None of these should throw without a T prefix, because they are unambiguously time strings: const unambiguousStrings = [ - "2021-13", // 13 is not a month - "202113", // ditto - "0000-00", // 0 is not a month - "000000", // ditto - "1314", // 13 is not a month - "13-14", // ditto - "1232", // 32 is not a day - "0230", // 30 is not a day in February - "0631", // 31 is not a day in June - "0000", // 0 is neither a month nor a day - "00-00", // ditto + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + "2021-12[-12:00]", // HHMM-UU is ambiguous with YYYY-MM, but TZ disambiguates + "202112[UTC]", // HHMMSS is ambiguous with YYYYMM, but TZ disambiguates ]; unambiguousStrings.forEach((arg) => instance.withPlainTime(arg));