mirror of https://github.com/tc39/test262.git
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.
This commit is contained in:
parent
8dcc0e1955
commit
d8e8529e8d
|
@ -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));
|
||||
|
|
|
@ -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" }));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue