Intl Era Monthcode: Tests for difference around Gregorian-like leap years

Adds tests for since and until in the four calendars with Gregorian-like
leap years (buddhist, gregory, japanese, roc).
This commit is contained in:
Philip Chimento 2025-11-18 20:48:21 -08:00 committed by Ms2ger
parent 4246feccce
commit 1648f70ba4
24 changed files with 2448 additions and 0 deletions

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.since
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.PlainDate.from({ year: 2503, monthCode: "M02", day: 16, calendar }, options);
const date25620101 = Temporal.PlainDate.from({ year: 2562, monthCode: "M01", day: 1, calendar }, options);
const date25620201 = Temporal.PlainDate.from({ year: 2562, monthCode: "M02", day: 1, calendar }, options);
const date25620301 = Temporal.PlainDate.from({ year: 2562, monthCode: "M03", day: 1, calendar }, options);
const date25620601 = Temporal.PlainDate.from({ year: 2562, monthCode: "M06", day: 1, calendar }, options);
const date25630101 = Temporal.PlainDate.from({ year: 2563, monthCode: "M01", day: 1, calendar }, options);
const date25630201 = Temporal.PlainDate.from({ year: 2563, monthCode: "M02", day: 1, calendar }, options);
const date25630301 = Temporal.PlainDate.from({ year: 2563, monthCode: "M03", day: 1, calendar }, options);
const date25630315 = Temporal.PlainDate.from({ year: 2563, monthCode: "M03", day: 15, calendar }, options);
const date25630601 = Temporal.PlainDate.from({ year: 2563, monthCode: "M06", day: 1, calendar }, options);
const date25640101 = Temporal.PlainDate.from({ year: 2564, monthCode: "M01", day: 1, calendar }, options);
const date25640107 = Temporal.PlainDate.from({ year: 2564, monthCode: "M01", day: 7, calendar }, options);
const date25640201 = Temporal.PlainDate.from({ year: 2564, monthCode: "M02", day: 1, calendar }, options);
const date25640228 = Temporal.PlainDate.from({ year: 2564, monthCode: "M02", day: 28, calendar }, options);
const date25640307 = Temporal.PlainDate.from({ year: 2564, monthCode: "M03", day: 7, calendar }, options);
const date25640315 = Temporal.PlainDate.from({ year: 2564, monthCode: "M03", day: 15, calendar }, options);
const date25640601 = Temporal.PlainDate.from({ year: 2564, monthCode: "M06", day: 1, calendar }, options);
const date25650228 = Temporal.PlainDate.from({ year: 2565, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, -365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, -366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, -366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, -365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, -28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.since
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDate.from({ year: 1960, monthCode: "M02", day: 16, calendar }, options);
const date20190101 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options);
const date20190201 = Temporal.PlainDate.from({ year: 2019, monthCode: "M02", day: 1, calendar }, options);
const date20190301 = Temporal.PlainDate.from({ year: 2019, monthCode: "M03", day: 1, calendar }, options);
const date20190601 = Temporal.PlainDate.from({ year: 2019, monthCode: "M06", day: 1, calendar }, options);
const date20200101 = Temporal.PlainDate.from({ year: 2020, monthCode: "M01", day: 1, calendar }, options);
const date20200201 = Temporal.PlainDate.from({ year: 2020, monthCode: "M02", day: 1, calendar }, options);
const date20200301 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options);
const date20200315 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 15, calendar }, options);
const date20200601 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options);
const date20210101 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options);
const date20210107 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 7, calendar }, options);
const date20210201 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 1, calendar }, options);
const date20210228 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 28, calendar }, options);
const date20210307 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 7, calendar }, options);
const date20210315 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 15, calendar }, options);
const date20210601 = Temporal.PlainDate.from({ year: 2021, monthCode: "M06", day: 1, calendar }, options);
const date20220228 = Temporal.PlainDate.from({ year: 2022, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.since
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDate.from({ year: 1960, monthCode: "M02", day: 16, calendar }, options);
const date20190101 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options);
const date20190201 = Temporal.PlainDate.from({ year: 2019, monthCode: "M02", day: 1, calendar }, options);
const date20190301 = Temporal.PlainDate.from({ year: 2019, monthCode: "M03", day: 1, calendar }, options);
const date20190601 = Temporal.PlainDate.from({ year: 2019, monthCode: "M06", day: 1, calendar }, options);
const date20200101 = Temporal.PlainDate.from({ year: 2020, monthCode: "M01", day: 1, calendar }, options);
const date20200201 = Temporal.PlainDate.from({ year: 2020, monthCode: "M02", day: 1, calendar }, options);
const date20200301 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options);
const date20200315 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 15, calendar }, options);
const date20200601 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options);
const date20210101 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options);
const date20210107 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 7, calendar }, options);
const date20210201 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 1, calendar }, options);
const date20210228 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 28, calendar }, options);
const date20210307 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 7, calendar }, options);
const date20210315 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 15, calendar }, options);
const date20210601 = Temporal.PlainDate.from({ year: 2021, monthCode: "M06", day: 1, calendar }, options);
const date20220228 = Temporal.PlainDate.from({ year: 2022, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.since
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.PlainDate.from({ year: 49, monthCode: "M02", day: 16, calendar }, options);
const date1080101 = Temporal.PlainDate.from({ year: 108, monthCode: "M01", day: 1, calendar }, options);
const date1080201 = Temporal.PlainDate.from({ year: 108, monthCode: "M02", day: 1, calendar }, options);
const date1080301 = Temporal.PlainDate.from({ year: 108, monthCode: "M03", day: 1, calendar }, options);
const date1080601 = Temporal.PlainDate.from({ year: 108, monthCode: "M06", day: 1, calendar }, options);
const date1090101 = Temporal.PlainDate.from({ year: 109, monthCode: "M01", day: 1, calendar }, options);
const date1090201 = Temporal.PlainDate.from({ year: 109, monthCode: "M02", day: 1, calendar }, options);
const date1090301 = Temporal.PlainDate.from({ year: 109, monthCode: "M03", day: 1, calendar }, options);
const date1090315 = Temporal.PlainDate.from({ year: 109, monthCode: "M03", day: 15, calendar }, options);
const date1090601 = Temporal.PlainDate.from({ year: 109, monthCode: "M06", day: 1, calendar }, options);
const date1100101 = Temporal.PlainDate.from({ year: 110, monthCode: "M01", day: 1, calendar }, options);
const date1100107 = Temporal.PlainDate.from({ year: 110, monthCode: "M01", day: 7, calendar }, options);
const date1100201 = Temporal.PlainDate.from({ year: 110, monthCode: "M02", day: 1, calendar }, options);
const date1100228 = Temporal.PlainDate.from({ year: 110, monthCode: "M02", day: 28, calendar }, options);
const date1100307 = Temporal.PlainDate.from({ year: 110, monthCode: "M03", day: 7, calendar }, options);
const date1100315 = Temporal.PlainDate.from({ year: 110, monthCode: "M03", day: 15, calendar }, options);
const date1100601 = Temporal.PlainDate.from({ year: 110, monthCode: "M06", day: 1, calendar }, options);
const date1110228 = Temporal.PlainDate.from({ year: 111, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, -365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, -366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, -366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, -365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, -28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.until
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.PlainDate.from({ year: 2503, monthCode: "M02", day: 16, calendar }, options);
const date25620101 = Temporal.PlainDate.from({ year: 2562, monthCode: "M01", day: 1, calendar }, options);
const date25620201 = Temporal.PlainDate.from({ year: 2562, monthCode: "M02", day: 1, calendar }, options);
const date25620301 = Temporal.PlainDate.from({ year: 2562, monthCode: "M03", day: 1, calendar }, options);
const date25620601 = Temporal.PlainDate.from({ year: 2562, monthCode: "M06", day: 1, calendar }, options);
const date25630101 = Temporal.PlainDate.from({ year: 2563, monthCode: "M01", day: 1, calendar }, options);
const date25630201 = Temporal.PlainDate.from({ year: 2563, monthCode: "M02", day: 1, calendar }, options);
const date25630301 = Temporal.PlainDate.from({ year: 2563, monthCode: "M03", day: 1, calendar }, options);
const date25630315 = Temporal.PlainDate.from({ year: 2563, monthCode: "M03", day: 15, calendar }, options);
const date25630601 = Temporal.PlainDate.from({ year: 2563, monthCode: "M06", day: 1, calendar }, options);
const date25640101 = Temporal.PlainDate.from({ year: 2564, monthCode: "M01", day: 1, calendar }, options);
const date25640107 = Temporal.PlainDate.from({ year: 2564, monthCode: "M01", day: 7, calendar }, options);
const date25640201 = Temporal.PlainDate.from({ year: 2564, monthCode: "M02", day: 1, calendar }, options);
const date25640228 = Temporal.PlainDate.from({ year: 2564, monthCode: "M02", day: 28, calendar }, options);
const date25640307 = Temporal.PlainDate.from({ year: 2564, monthCode: "M03", day: 7, calendar }, options);
const date25640315 = Temporal.PlainDate.from({ year: 2564, monthCode: "M03", day: 15, calendar }, options);
const date25640601 = Temporal.PlainDate.from({ year: 2564, monthCode: "M06", day: 1, calendar }, options);
const date25650228 = Temporal.PlainDate.from({ year: 2565, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, 365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, 366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, 366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, 365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, 28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.until
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDate.from({ year: 1960, monthCode: "M02", day: 16, calendar }, options);
const date20190101 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options);
const date20190201 = Temporal.PlainDate.from({ year: 2019, monthCode: "M02", day: 1, calendar }, options);
const date20190301 = Temporal.PlainDate.from({ year: 2019, monthCode: "M03", day: 1, calendar }, options);
const date20190601 = Temporal.PlainDate.from({ year: 2019, monthCode: "M06", day: 1, calendar }, options);
const date20200101 = Temporal.PlainDate.from({ year: 2020, monthCode: "M01", day: 1, calendar }, options);
const date20200201 = Temporal.PlainDate.from({ year: 2020, monthCode: "M02", day: 1, calendar }, options);
const date20200301 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options);
const date20200315 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 15, calendar }, options);
const date20200601 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options);
const date20210101 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options);
const date20210107 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 7, calendar }, options);
const date20210201 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 1, calendar }, options);
const date20210228 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 28, calendar }, options);
const date20210307 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 7, calendar }, options);
const date20210315 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 15, calendar }, options);
const date20210601 = Temporal.PlainDate.from({ year: 2021, monthCode: "M06", day: 1, calendar }, options);
const date20220228 = Temporal.PlainDate.from({ year: 2022, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.until
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDate.from({ year: 1960, monthCode: "M02", day: 16, calendar }, options);
const date20190101 = Temporal.PlainDate.from({ year: 2019, monthCode: "M01", day: 1, calendar }, options);
const date20190201 = Temporal.PlainDate.from({ year: 2019, monthCode: "M02", day: 1, calendar }, options);
const date20190301 = Temporal.PlainDate.from({ year: 2019, monthCode: "M03", day: 1, calendar }, options);
const date20190601 = Temporal.PlainDate.from({ year: 2019, monthCode: "M06", day: 1, calendar }, options);
const date20200101 = Temporal.PlainDate.from({ year: 2020, monthCode: "M01", day: 1, calendar }, options);
const date20200201 = Temporal.PlainDate.from({ year: 2020, monthCode: "M02", day: 1, calendar }, options);
const date20200301 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 1, calendar }, options);
const date20200315 = Temporal.PlainDate.from({ year: 2020, monthCode: "M03", day: 15, calendar }, options);
const date20200601 = Temporal.PlainDate.from({ year: 2020, monthCode: "M06", day: 1, calendar }, options);
const date20210101 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options);
const date20210107 = Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 7, calendar }, options);
const date20210201 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 1, calendar }, options);
const date20210228 = Temporal.PlainDate.from({ year: 2021, monthCode: "M02", day: 28, calendar }, options);
const date20210307 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 7, calendar }, options);
const date20210315 = Temporal.PlainDate.from({ year: 2021, monthCode: "M03", day: 15, calendar }, options);
const date20210601 = Temporal.PlainDate.from({ year: 2021, monthCode: "M06", day: 1, calendar }, options);
const date20220228 = Temporal.PlainDate.from({ year: 2022, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.until
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.PlainDate.from({ year: 49, monthCode: "M02", day: 16, calendar }, options);
const date1080101 = Temporal.PlainDate.from({ year: 108, monthCode: "M01", day: 1, calendar }, options);
const date1080201 = Temporal.PlainDate.from({ year: 108, monthCode: "M02", day: 1, calendar }, options);
const date1080301 = Temporal.PlainDate.from({ year: 108, monthCode: "M03", day: 1, calendar }, options);
const date1080601 = Temporal.PlainDate.from({ year: 108, monthCode: "M06", day: 1, calendar }, options);
const date1090101 = Temporal.PlainDate.from({ year: 109, monthCode: "M01", day: 1, calendar }, options);
const date1090201 = Temporal.PlainDate.from({ year: 109, monthCode: "M02", day: 1, calendar }, options);
const date1090301 = Temporal.PlainDate.from({ year: 109, monthCode: "M03", day: 1, calendar }, options);
const date1090315 = Temporal.PlainDate.from({ year: 109, monthCode: "M03", day: 15, calendar }, options);
const date1090601 = Temporal.PlainDate.from({ year: 109, monthCode: "M06", day: 1, calendar }, options);
const date1100101 = Temporal.PlainDate.from({ year: 110, monthCode: "M01", day: 1, calendar }, options);
const date1100107 = Temporal.PlainDate.from({ year: 110, monthCode: "M01", day: 7, calendar }, options);
const date1100201 = Temporal.PlainDate.from({ year: 110, monthCode: "M02", day: 1, calendar }, options);
const date1100228 = Temporal.PlainDate.from({ year: 110, monthCode: "M02", day: 28, calendar }, options);
const date1100307 = Temporal.PlainDate.from({ year: 110, monthCode: "M03", day: 7, calendar }, options);
const date1100315 = Temporal.PlainDate.from({ year: 110, monthCode: "M03", day: 15, calendar }, options);
const date1100601 = Temporal.PlainDate.from({ year: 110, monthCode: "M06", day: 1, calendar }, options);
const date1110228 = Temporal.PlainDate.from({ year: 111, monthCode: "M02", day: 28, calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, 365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, 366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, 366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, 365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, 28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.since
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.PlainDateTime.from({ year: 2503, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date25620101 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620201 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620301 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620601 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630101 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630201 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630301 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630315 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date25630601 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640101 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640107 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date25640201 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640228 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date25640307 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date25640315 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date25640601 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25650228 = Temporal.PlainDateTime.from({ year: 2565, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, -365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, -366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, -366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, -365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, -28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.since
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date20190101 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190201 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190301 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190601 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200101 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200201 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200301 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200315 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20200601 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210101 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210107 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210201 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210228 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date20210307 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210315 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20210601 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20220228 = Temporal.PlainDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.since
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date20190101 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190201 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190301 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190601 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200101 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200201 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200301 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200315 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20200601 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210101 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210107 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210201 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210228 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date20210307 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210315 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20210601 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20220228 = Temporal.PlainDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.since
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.PlainDateTime.from({ year: 49, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date1080101 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080201 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080301 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080601 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090101 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090201 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090301 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090315 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date1090601 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100101 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100107 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date1100201 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100228 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date1100307 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date1100315 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date1100601 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1110228 = Temporal.PlainDateTime.from({ year: 111, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, -365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, -366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, -366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, -365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, -28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.until
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.PlainDateTime.from({ year: 2503, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date25620101 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620201 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620301 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date25620601 = Temporal.PlainDateTime.from({ year: 2562, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630101 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630201 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630301 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date25630315 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date25630601 = Temporal.PlainDateTime.from({ year: 2563, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640101 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640107 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date25640201 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date25640228 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date25640307 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date25640315 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date25640601 = Temporal.PlainDateTime.from({ year: 2564, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date25650228 = Temporal.PlainDateTime.from({ year: 2565, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, 365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, 366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, 366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, 365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, 28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.until
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date20190101 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190201 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190301 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190601 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200101 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200201 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200301 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200315 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20200601 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210101 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210107 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210201 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210228 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date20210307 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210315 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20210601 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20220228 = Temporal.PlainDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.until
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.PlainDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date20190101 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190201 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190301 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20190601 = Temporal.PlainDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200101 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200201 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200301 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date20200315 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20200601 = Temporal.PlainDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210101 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210107 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210201 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date20210228 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date20210307 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date20210315 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date20210601 = Temporal.PlainDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date20220228 = Temporal.PlainDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.prototype.until
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.PlainDateTime.from({ year: 49, monthCode: "M02", day: 16, hour: 12, minute: 34, calendar }, options);
const date1080101 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080201 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080301 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date1080601 = Temporal.PlainDateTime.from({ year: 108, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090101 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090201 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090301 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
const date1090315 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date1090601 = Temporal.PlainDateTime.from({ year: 109, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100101 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100107 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M01", day: 7, hour: 12, minute: 34, calendar }, options);
const date1100201 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M02", day: 1, hour: 12, minute: 34, calendar }, options);
const date1100228 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const date1100307 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M03", day: 7, hour: 12, minute: 34, calendar }, options);
const date1100315 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M03", day: 15, hour: 12, minute: 34, calendar }, options);
const date1100601 = Temporal.PlainDateTime.from({ year: 110, monthCode: "M06", day: 1, hour: 12, minute: 34, calendar }, options);
const date1110228 = Temporal.PlainDateTime.from({ year: 111, monthCode: "M02", day: 28, hour: 12, minute: 34, calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, 365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, 366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, 366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, 365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, 28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.since
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.ZonedDateTime.from({ year: 2503, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620101 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620201 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620301 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620601 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630101 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630201 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630301 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630315 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630601 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640101 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640107 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640201 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640228 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640307 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640315 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640601 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25650228 = Temporal.ZonedDateTime.from({ year: 2565, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, -365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, -366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, -366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, -365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, -28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.since
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.ZonedDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190101 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190201 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190301 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190601 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200101 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200201 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200301 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200315 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200601 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210101 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210107 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210201 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210228 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210307 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210315 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210601 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20220228 = Temporal.ZonedDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.since
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.ZonedDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190101 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190201 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190301 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190601 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200101 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200201 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200301 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200315 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200601 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210101 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210107 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210201 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210228 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210307 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210315 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210601 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20220228 = Temporal.ZonedDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, -365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, -366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, -366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, -365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, -28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.since
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.ZonedDateTime.from({ year: 49, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080101 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080201 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080301 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080601 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090101 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090201 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090301 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090315 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090601 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100101 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100107 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100201 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100228 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100307 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100315 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100601 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1110228 = Temporal.ZonedDateTime.from({ year: 111, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", -61, 0, 0, -27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", 61, 0, 0, 28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, -52, -2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, -52, -1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, -365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, -366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, -366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, -365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, -28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, -29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.since(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.until
description: Check various basic calculations involving leap years (buddhist calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "buddhist";
const options = { overflow: "reject" };
const date25030216 = Temporal.ZonedDateTime.from({ year: 2503, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620101 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620201 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620301 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25620601 = Temporal.ZonedDateTime.from({ year: 2562, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630101 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630201 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630301 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630315 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25630601 = Temporal.ZonedDateTime.from({ year: 2563, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640101 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640107 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640201 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640228 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640307 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640315 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25640601 = Temporal.ZonedDateTime.from({ year: 2564, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date25650228 = Temporal.ZonedDateTime.from({ year: 2565, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date25640107, date25640307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date25030216, date25640315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date25030216, date25630315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date25640315, date25030216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date25630315, date25030216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date25640307, date25640107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date25630201, date25640201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date25640228, date25650228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date25620101, date25630101, "length of year from January 2562",
["days", 0, 0, 0, 365],
],
[
date25630101, date25640101, "length of year from January 2563",
["days", 0, 0, 0, 366],
],
[
date25620601, date25630601, "length of year from June 2562",
["days", 0, 0, 0, 366],
],
[
date25630601, date25640601, "length of year from June 2563",
["days", 0, 0, 0, 365],
],
[
date25620201, date25620301, "length of Feb 2562",
["days", 0, 0, 0, 28],
],
[
date25630201, date25630301, "length of Feb 2563",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.until
description: Check various basic calculations involving leap years (gregory calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "gregory";
const options = { overflow: "reject" };
const date19600216 = Temporal.ZonedDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190101 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190201 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190301 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190601 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200101 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200201 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200301 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200315 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200601 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210101 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210107 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210201 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210228 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210307 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210315 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210601 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20220228 = Temporal.ZonedDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.until
description: Check various basic calculations involving leap years (japanese calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "japanese";
const options = { overflow: "reject" };
const date19600216 = Temporal.ZonedDateTime.from({ year: 1960, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190101 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190201 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190301 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20190601 = Temporal.ZonedDateTime.from({ year: 2019, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200101 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200201 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200301 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200315 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20200601 = Temporal.ZonedDateTime.from({ year: 2020, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210101 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210107 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210201 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210228 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210307 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210315 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20210601 = Temporal.ZonedDateTime.from({ year: 2021, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date20220228 = Temporal.ZonedDateTime.from({ year: 2022, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date20210107, date20210307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date19600216, date20210315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date19600216, date20200315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date20210315, date19600216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date20200315, date19600216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date20210307, date20210107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date20200201, date20210201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date20210228, date20220228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date20190101, date20200101, "length of year from January 2019",
["days", 0, 0, 0, 365],
],
[
date20200101, date20210101, "length of year from January 2020",
["days", 0, 0, 0, 366],
],
[
date20190601, date20200601, "length of year from June 2019",
["days", 0, 0, 0, 366],
],
[
date20200601, date20210601, "length of year from June 2020",
["days", 0, 0, 0, 365],
],
[
date20190201, date20190301, "length of Feb 2019",
["days", 0, 0, 0, 28],
],
[
date20200201, date20200301, "length of Feb 2020",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}

View File

@ -0,0 +1,102 @@
// Copyright (C) 2025 Igalia, S.L., and the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.until
description: Check various basic calculations involving leap years (roc calendar)
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/
const calendar = "roc";
const options = { overflow: "reject" };
const date0490216 = Temporal.ZonedDateTime.from({ year: 49, monthCode: "M02", day: 16, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080101 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080201 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080301 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1080601 = Temporal.ZonedDateTime.from({ year: 108, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090101 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090201 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090301 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090315 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1090601 = Temporal.ZonedDateTime.from({ year: 109, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100101 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100107 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M01", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100201 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M02", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100228 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100307 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M03", day: 7, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100315 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M03", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1100601 = Temporal.ZonedDateTime.from({ year: 110, monthCode: "M06", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const date1110228 = Temporal.ZonedDateTime.from({ year: 111, monthCode: "M02", day: 28, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
const tests = [
[
date1100107, date1100307, "2 months in same year across Feb 28",
["years", 0, 2, 0, 0],
["months", 0, 2, 0, 0],
],
[
date0490216, date1100315, "61 years, 27 days in common year",
["years", 61, 0, 0, 27],
],
[
date0490216, date1090315, "60 years, 28 days in leap year",
["years", 60, 0, 0, 28],
],
[
date1100315, date0490216, "negative 61 years, 28 days in common year",
["years", -61, 0, 0, -28],
],
[
date1090315, date0490216, "negative 60 years, 28 days in leap year",
["years", -60, 0, 0, -28],
],
[
date1100307, date1100107, "negative 2 month in same year across Feb 28",
["years", 0, -2, 0, 0],
["months", 0, -2, 0, 0],
],
[
date1090201, date1100201, "year including leap day",
["weeks", 0, 0, 52, 2],
],
[
date1100228, date1110228, "year not including leap day",
["weeks", 0, 0, 52, 1],
],
[
date1080101, date1090101, "length of year from January 108",
["days", 0, 0, 0, 365],
],
[
date1090101, date1100101, "length of year from January 109",
["days", 0, 0, 0, 366],
],
[
date1080601, date1090601, "length of year from June 108",
["days", 0, 0, 0, 366],
],
[
date1090601, date1100601, "length of year from June 109",
["days", 0, 0, 0, 365],
],
[
date1080201, date1080301, "length of Feb 108",
["days", 0, 0, 0, 28],
],
[
date1090201, date1090301, "length of Feb 109",
["days", 0, 0, 0, 29],
],
];
for (const [one, two, descr, ...units] of tests) {
for (const [largestUnit, years, months, weeks, days] of units) {
TemporalHelpers.assertDuration(
one.until(two, { largestUnit }),
years, months, weeks, days, 0, 0, 0, 0, 0, 0,
descr
);
}
}