mirror of
https://github.com/tc39/test262.git
synced 2025-06-26 08:50:33 +02:00
https://github.com/tc39/proposal-temporal/pull/1952 added support for time designator prefixes in PlainTime strings. This adds three tests to all entry points that convert an ISO string to a PlainTime: - no-implicit-midnight: ISO strings with only a date and no time are no longer accepted. Previously they were implicitly interpreted as 00:00. - with-time-designator: Tests that various forms of string with time designator are correctly parsed. - time-designator-required-for-disambiguation: Tests various cases where a string without a time designator is ambiguous and therefore the time designator is required, as well as various cases that implementations might assume are ambiguous but in fact are not. This was a normative change that achieved consensus at the December 2021 TC39 meeting.
29 lines
838 B
JavaScript
29 lines
838 B
JavaScript
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.plaintime.compare
|
|
description: ISO 8601 time designator "T" allowed at the start of PlainTime strings
|
|
features: [Temporal, arrow-function]
|
|
---*/
|
|
|
|
const halfPast = new Temporal.PlainTime(0, 30);
|
|
const validStrings = [
|
|
"T00:30",
|
|
"t00:30",
|
|
"T0030",
|
|
"t0030",
|
|
"T00:30:00",
|
|
"t00:30:00",
|
|
"T003000",
|
|
"t003000",
|
|
"T00:30:00.000000000",
|
|
"t00:30:00.000000000",
|
|
"T003000.000000000",
|
|
"t003000.000000000",
|
|
];
|
|
validStrings.forEach((arg) => {
|
|
assert.sameValue(Temporal.PlainTime.compare(arg, halfPast), 0, `T prefix is accepted: ${arg} (first argument)`);
|
|
assert.sameValue(Temporal.PlainTime.compare(halfPast, arg), 0, `T prefix is accepted: ${arg} (second argument)`);
|
|
});
|