Temporal: Add tests for time zone annotation with critical flag

See https://github.com/tc39/proposal-temporal/pull/2397
Adds tests for ISO strings with named and numeric offset time zone
annotations, with and without the critical flag, with various combinations
of Z and offset in front of the annotation.
This commit is contained in:
Philip Chimento 2022-10-07 12:42:48 -07:00 committed by Ms2ger
parent bf3efa65fc
commit 2d015b700a
65 changed files with 2320 additions and 4 deletions

View File

@ -0,0 +1,40 @@
// 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.calendar.prototype.dateadd
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.dateAdd(arg, new Temporal.Duration());
TemporalHelpers.assertPlainDate(
result,
2000, 5, "M05", 2,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.calendar.prototype.dateuntil
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.dateUntil(arg, arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.day
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.day(arg);
assert.sameValue(
result,
2,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.dayofweek
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.dayOfWeek(arg);
assert.sameValue(
result,
2,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.dayofyear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.dayOfYear(arg);
assert.sameValue(
result,
123,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.daysinmonth
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.daysInMonth(arg);
assert.sameValue(
result,
31,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.daysinweek
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.daysInWeek(arg);
assert.sameValue(
result,
7,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.daysinyear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.daysInYear(arg);
assert.sameValue(
result,
366,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.inleapyear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.inLeapYear(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.month
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.month(arg);
assert.sameValue(
result,
5,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.monthcode
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.monthCode(arg);
assert.sameValue(
result,
"M05",
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.monthsinyear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.monthsInYear(arg);
assert.sameValue(
result,
12,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.weekofyear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.weekOfYear(arg);
assert.sameValue(
result,
18,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.year
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.year(arg);
assert.sameValue(
result,
2000,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,29 @@
// 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.instant.compare
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.Instant.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,29 @@
// 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.instant.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.Instant.from(arg);
assert.sameValue(
result.epochNanoseconds,
0n,
`time zone annotation (${description})`
);
});

View File

@ -38,12 +38,9 @@ const tests = [
['1976-11-18T15Z', 217177200000000000n],
['1976-11-18T15:23:30.123456789Z[u-ca=discord]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[+00]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[+00:00]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[-00]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[-00:00]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[+12]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[UTC]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[Europe/Paris]', 217178610123456789n],
['1976-11-18T15:23:30.123456789Z[NotATimeZone]', 217178610123456789n],
];

View File

@ -0,0 +1,31 @@
// 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.instant.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Instant(0n);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.instant.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Instant(0n);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.instant.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Instant(0n);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,37 @@
// 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.plaindate.compare
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainDate.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,38 @@
// 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.plaindate.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainDate.from(arg);
TemporalHelpers.assertPlainDate(
result,
2000, 5, "M05", 2,
`time zone annotation (${description})`
);
});

View File

@ -31,7 +31,6 @@ const tests = [
["+0019761118T15:23:30.1+0000", 1976, 11, "M11", 18],
["+0019761118T152330.1+00:00", 1976, 11, "M11", 18],
["+0019761118T152330.1+0000", 1976, 11, "M11", 18],
["2020-01-01[Asia/Kolkata]", 2020, 1, "M01", 1],
];
for (const [input, ...expected] of tests) {

View File

@ -0,0 +1,39 @@
// 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.plaindate.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDate(2000, 5, 2);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.plaindate.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDate(2000, 5, 2);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,48 @@
// 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.plaindate.prototype.toplaindatetime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainDate(2000, 5, 2);
tests.forEach(([arg, description]) => {
const result = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(
result,
2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,47 @@
// 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.plaindate.prototype.tozoneddatetime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainDate(2000, 5, 2);
tests.forEach(([arg, description]) => {
const result = instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" });
assert.sameValue(
result.epochNanoseconds,
957_270_896_987_654_321n,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.plaindate.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDate(2000, 5, 2);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,29 @@
// 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.plaindatetime.compare
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainDateTime.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,30 @@
// 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.plaindatetime.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainDateTime.from(arg);
TemporalHelpers.assertPlainDateTime(
result,
1976, 11, "M11", 18, 15, 23, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.plaindatetime.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.plaindatetime.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.plaindatetime.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.plaindatetime.prototype.withplaindate
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
tests.forEach(([arg, description]) => {
const result = instance.withPlainDate(arg);
TemporalHelpers.assertPlainDateTime(
result,
2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,48 @@
// 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.plaindatetime.prototype.withplaintime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
tests.forEach(([arg, description]) => {
const result = instance.withPlainTime(arg);
TemporalHelpers.assertPlainDateTime(
result,
1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,30 @@
// 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.plainmonthday.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1976-05-02T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-05-02T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-05-02T15:23[+00:00]", "numeric, with no offset"],
["1976-05-02T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-05-02T15:23+00:00[UTC]", "named, with offset"],
["1976-05-02T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainMonthDay.from(arg);
TemporalHelpers.assertPlainMonthDay(
result,
"M05", 2,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.plainmonthday.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1976-05-02T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-05-02T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-05-02T15:23[+00:00]", "numeric, with no offset"],
["1976-05-02T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-05-02T15:23+00:00[UTC]", "named, with offset"],
["1976-05-02T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainMonthDay(5, 2);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,45 @@
// 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: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainTime.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,46 @@
// 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.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainTime.from(arg);
TemporalHelpers.assertPlainTime(
result,
12, 34, 56, 987, 654, 321,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,47 @@
// 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.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,48 @@
// 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.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.prototype.toplaindatetime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
tests.forEach(([arg, description]) => {
const result = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(
result,
2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.prototype.tozoneddatetime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
tests.forEach(([arg, description]) => {
const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" });
assert.sameValue(
result.epochNanoseconds,
957_270_896_987_654_321n,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,48 @@
// 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.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,29 @@
// 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.plainyearmonth.compare
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"],
["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["2019-12-15T15:23[+00:00]", "numeric, with no offset"],
["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"],
["2019-12-15T15:23+00:00[UTC]", "named, with offset"],
["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"],
["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainYearMonth.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,30 @@
// 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.plainyearmonth.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"],
["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["2019-12-15T15:23[+00:00]", "numeric, with no offset"],
["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"],
["2019-12-15T15:23+00:00[UTC]", "named, with offset"],
["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"],
["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.PlainYearMonth.from(arg);
TemporalHelpers.assertPlainYearMonth(
result,
2019, 12, "M12",
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.plainyearmonth.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"],
["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["2019-12-15T15:23[+00:00]", "numeric, with no offset"],
["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"],
["2019-12-15T15:23+00:00[UTC]", "named, with offset"],
["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"],
["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainYearMonth(2019, 12);
tests.forEach(([arg, description]) => {
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.plainyearmonth.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"],
["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["2019-12-15T15:23[+00:00]", "numeric, with no offset"],
["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"],
["2019-12-15T15:23+00:00[UTC]", "named, with offset"],
["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"],
["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainYearMonth(2019, 12);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.plainyearmonth.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"],
["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["2019-12-15T15:23[+00:00]", "numeric, with no offset"],
["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"],
["2019-12-15T15:23+00:00[UTC]", "named, with offset"],
["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"],
["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.PlainYearMonth(2019, 12);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.timezone.prototype.getinstantfor
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getInstantFor(arg);
assert.sameValue(
result.epochNanoseconds,
217_178_580_000_000_000n,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.timezone.prototype.getnexttransition
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.timezone.prototype.getoffsetnanosecondsfor
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getOffsetNanosecondsFor(arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.timezone.prototype.getoffsetstringfor
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getOffsetStringFor(arg);
assert.sameValue(
result,
"+00:00",
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.timezone.prototype.getplaindatetimefor
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPlainDateTimeFor(arg);
TemporalHelpers.assertPlainDateTime(
result,
1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,32 @@
// 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.timezone.prototype.getpossibleinstantsfor
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [compareArray.js]
---*/
const tests = [
["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"],
["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"],
["1976-11-18T15:23[+00:00]", "numeric, with no offset"],
["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"],
["1976-11-18T15:23+00:00[UTC]", "named, with offset"],
["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"],
["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPossibleInstantsFor(arg);
assert.compareArray(
result.map(i => i.epochNanoseconds),
[217_178_580_000_000_000n],
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,31 @@
// 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.timezone.prototype.getprevioustransition
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,33 @@
// 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.zoneddatetime.compare
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00[UTC]", "named, with no offset"],
["1970-01-01T00:00[!UTC]", "named, with ! and no offset"],
["1970-01-01T00:00[+00:00]", "numeric, with no offset"],
["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"],
["1970-01-01T00:00Z[UTC]", "named, with Z"],
["1970-01-01T00:00Z[!UTC]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"],
["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"],
];
tests.forEach(([arg, description]) => {
const result = Temporal.ZonedDateTime.compare(arg, arg);
assert.sameValue(
result,
0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,33 @@
// 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.zoneddatetime.from
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00[UTC]", "UTC", "named, with no offset"],
["1970-01-01T00:00[!UTC]", "UTC", "named, with ! and no offset"],
["1970-01-01T00:00[+00:00]", "+00:00", "numeric, with no offset"],
["1970-01-01T00:00[!+00:00]", "+00:00", "numeric, with ! and no offset"],
["1970-01-01T00:00Z[UTC]", "UTC", "named, with Z"],
["1970-01-01T00:00Z[!UTC]", "UTC", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "+00:00", "numeric, with Z"],
["1970-01-01T00:00Z[!+00:00]", "+00:00", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "UTC", "named, with offset"],
["1970-01-01T00:00+00:00[!UTC]", "UTC", "named, with offset and !"],
["1970-01-01T00:00+00:00[+00:00]", "+00:00", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+00:00]", "+00:00", "numeric, with offset and !"],
];
tests.forEach(([arg, expectedZone, description]) => {
const result = Temporal.ZonedDateTime.from(arg);
assert.sameValue(
result.timeZone.toString(),
expectedZone,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,35 @@
// 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.zoneddatetime.prototype.equals
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00[UTC]", "UTC", "named, with no offset"],
["1970-01-01T00:00[!UTC]", "UTC", "named, with ! and no offset"],
["1970-01-01T00:00[+00:00]", "+00:00", "numeric, with no offset"],
["1970-01-01T00:00[!+00:00]", "+00:00", "numeric, with ! and no offset"],
["1970-01-01T00:00Z[UTC]", "UTC", "named, with Z"],
["1970-01-01T00:00Z[!UTC]", "UTC", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "+00:00", "numeric, with Z"],
["1970-01-01T00:00Z[!+00:00]", "+00:00", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "UTC", "named, with offset"],
["1970-01-01T00:00+00:00[!UTC]", "UTC", "named, with offset and !"],
["1970-01-01T00:00+00:00[+00:00]", "+00:00", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+00:00]", "+00:00", "numeric, with offset and !"],
];
tests.forEach(([arg, expectedZone, description]) => {
const timeZone = new Temporal.TimeZone(expectedZone);
const instance = new Temporal.ZonedDateTime(0n, timeZone);
const result = instance.equals(arg);
assert.sameValue(
result,
true,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,37 @@
// 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.zoneddatetime.prototype.since
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1970-01-01T00:00[UTC]", "named, with no offset"],
["1970-01-01T00:00[!UTC]", "named, with ! and no offset"],
["1970-01-01T00:00[+00:00]", "numeric, with no offset"],
["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"],
["1970-01-01T00:00Z[UTC]", "named, with Z"],
["1970-01-01T00:00Z[!UTC]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"],
["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"],
];
const timeZone = new Temporal.TimeZone("UTC");
const instance = new Temporal.ZonedDateTime(0n, timeZone);
tests.forEach(([arg, description]) => {
const result = instance.since(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,37 @@
// 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.zoneddatetime.prototype.until
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
includes: [temporalHelpers.js]
---*/
const tests = [
["1970-01-01T00:00[UTC]", "named, with no offset"],
["1970-01-01T00:00[!UTC]", "named, with ! and no offset"],
["1970-01-01T00:00[+00:00]", "numeric, with no offset"],
["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"],
["1970-01-01T00:00Z[UTC]", "named, with Z"],
["1970-01-01T00:00Z[!UTC]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"],
["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"],
];
const timeZone = new Temporal.TimeZone("UTC");
const instance = new Temporal.ZonedDateTime(0n, timeZone);
tests.forEach(([arg, description]) => {
const result = instance.until(arg);
TemporalHelpers.assertDuration(
result,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,40 @@
// 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.zoneddatetime.prototype.withplaindate
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const timeZone = new Temporal.TimeZone("UTC");
const instance = new Temporal.ZonedDateTime(0n, timeZone);
tests.forEach(([arg, description]) => {
const result = instance.withPlainDate(arg);
assert.sameValue(
result.epochNanoseconds,
957_225_600_000_000_000n,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,48 @@
// 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.zoneddatetime.prototype.withplaintime
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"],
["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"],
["12:34:56.987654321[+00:00]", "numeric, with no offset"],
["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"],
["T12:34:56.987654321[UTC]", "named, with T and no offset"],
["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"],
["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"],
["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"],
["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"],
["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"],
["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"],
["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"],
["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"],
["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"],
["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"],
["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"],
["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"],
["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"],
["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"],
["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"],
["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"],
["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"],
];
const timeZone = new Temporal.TimeZone("UTC");
const instance = new Temporal.ZonedDateTime(0n, timeZone);
tests.forEach(([arg, description]) => {
const result = instance.withPlainTime(arg);
assert.sameValue(
result.epochNanoseconds,
45_296_987_654_321n,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.era
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.era(arg);
assert.sameValue(
result,
undefined,
`time zone annotation (${description})`
);
});

View File

@ -0,0 +1,39 @@
// 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.calendar.prototype.erayear
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"],
["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"],
["2000-05-02[+00:00]", "numeric, with no time and no offset"],
["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"],
["2000-05-02+00:00[UTC]", "named, with offset and no time"],
["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"],
["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"],
["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"],
["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"],
["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"],
["2000-05-02T15:23[-02:30]", "numeric, with no offset"],
["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"],
["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"],
["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"],
["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"],
["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"],
];
const instance = new Temporal.Calendar("iso8601");
tests.forEach(([arg, description]) => {
const result = instance.eraYear(arg);
assert.sameValue(
result,
undefined,
`time zone annotation (${description})`
);
});