mirror of
https://github.com/tc39/test262.git
synced 2025-11-28 17:43:19 +01:00
Temporal: Add tests for date differencing across era boundaries for Hijri and Ethiopic calendars
This commit is contained in:
parent
eb438e25e0
commit
3b2bc2c5b6
90
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options);
|
||||
const am1 = Temporal.PlainDate.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, calendar }, options);
|
||||
const am2000 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options);
|
||||
const am2005 = Temporal.PlainDate.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, calendar }, options);
|
||||
const aa5450 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options);
|
||||
const aa5455 = Temporal.PlainDate.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, calendar }, options);
|
||||
const am5 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
90
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options);
|
||||
const am1 = Temporal.PlainDate.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, calendar }, options);
|
||||
const am2000 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options);
|
||||
const am2005 = Temporal.PlainDate.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, calendar }, options);
|
||||
const aa5450 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options);
|
||||
const aa5455 = Temporal.PlainDate.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, calendar }, options);
|
||||
const am5 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/PlainDate/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDate.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
const bh2 = Temporal.PlainDate.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, calendar }, options);
|
||||
const bh1 = Temporal.PlainDate.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah1 = Temporal.PlainDate.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
|
||||
const ah2 = Temporal.PlainDate.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, calendar }, options);
|
||||
const ah5 = Temporal.PlainDate.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
90
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const am1 = Temporal.PlainDateTime.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const am2000 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const am2005 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const aa5450 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
|
||||
const aa5455 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
|
||||
const am5 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
90
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const am1 = Temporal.PlainDateTime.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const am2000 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const am2005 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const aa5450 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
|
||||
const aa5455 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
|
||||
const am5 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/PlainDateTime/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const bh2 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const bh1 = Temporal.PlainDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah1 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
const ah2 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
|
||||
const ah5 = Temporal.PlainDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
90
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am1 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am2000 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am2005 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const aa5450 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const aa5455 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am5 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/since/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.since
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.since(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.since(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.since(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.since(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.since(two);
|
||||
const resultDaysISO = oneISO.since(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
90
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
90
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-ethiopic.js
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "ethiopic";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const aa5500 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am1 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 1, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am2000 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am2005 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2005, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const aa5450 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const aa5455 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5455, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const am5 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5500 AA to 1 AM
|
||||
[
|
||||
aa5500, am1,
|
||||
[1, 0, 0, 0, "1y from 5500 AA to 1 AM"],
|
||||
[0, 13, 0, 0, 0, "13mo from 5500 AA to 1 AM"],
|
||||
],
|
||||
[
|
||||
am1, aa5500,
|
||||
[-1, 0, 0, 0, "-1y backwards from 5500 AA to 1 AM"],
|
||||
[0, -13, 0, 0, 0, "-13mo backwards from 1 AM to 5500 AA"],
|
||||
],
|
||||
// From 2000 AM to 2005 AM
|
||||
[
|
||||
am2000, am2005,
|
||||
[5, 0, 0, 0, "5y from 2000 AM to 2005 AM"],
|
||||
[0, 65, 0, 0, "65mo from 2000 AM to 2005 AM"],
|
||||
],
|
||||
[
|
||||
am2005, am2000,
|
||||
[-5, 0, 0, 0, "-5y backwards from 2000 AM to 2005 AM"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 2000 AM to 2005 AM"],
|
||||
],
|
||||
// From 5450 AA to 5455 AA
|
||||
[
|
||||
aa5450, aa5455,
|
||||
[5, 0, 0, 0, "5y from 5450 AA to 5455 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5450 AA to 5455 AA"],
|
||||
],
|
||||
[
|
||||
aa5455, aa5450,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5450 AA to 5455 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5450 AA to 5455 AA"],
|
||||
],
|
||||
// From 5 AM to 5500 AA
|
||||
[
|
||||
aa5500, am5,
|
||||
[5, 0, 0, 0, "5y from 5 AM to 5500 AA"],
|
||||
[0, 65, 0, 0, "65mo from 5 AM to 5500 AA"],
|
||||
],
|
||||
[
|
||||
am5, aa5500,
|
||||
[-5, 0, 0, 0, "-5y backwards from 5 AM to 5500 AA"],
|
||||
[0, -65, 0, 0, "-65mo backwards from 5 AM to 5500 AA"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-civil.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-civil";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-tbla.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-tbla";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
77
test/intl402/Temporal/ZonedDateTime/prototype/until/era-boundary-islamic-umalqura.js
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.until
|
||||
description: Date difference works correctly across era boundaries
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal, Intl.Era-monthcode]
|
||||
---*/
|
||||
|
||||
const calendar = "islamic-umalqura";
|
||||
const options = { overflow: "reject" };
|
||||
|
||||
const bh5 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh2 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 2, monthCode: "M12", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const bh1 = Temporal.ZonedDateTime.from({ era: "bh", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah1 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah2 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 2, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
const ah5 = Temporal.ZonedDateTime.from({ era: "ah", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
|
||||
|
||||
const tests = [
|
||||
// From 5 BH to 5 AH
|
||||
[
|
||||
bh5, ah5,
|
||||
[9, 0, 0, 0, "9y from 5 BH to 5 AH (no year 0)"],
|
||||
[0, 108, 0, 0, 0, "108mo from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
[
|
||||
ah5, bh5,
|
||||
[-9, 0, 0, 0, "-9y backwards from 5 BH to 5 AH (no year 0)"],
|
||||
[0, -108, 0, 0, 0, "-108mo backwards from 5 BH to 5 AH (no year 0)"],
|
||||
],
|
||||
// AH-BH boundary
|
||||
[
|
||||
bh1, ah1,
|
||||
[1, 0, 0, 0, "1y from 1 BH to 1 AH"],
|
||||
[0, 12, 0, 0, "12mo from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
ah1, bh1,
|
||||
[-1, 0, 0, 0, "-1y backwards from 1 BH to 1 AH"],
|
||||
[0, -12, 0, 0, "-12mo backwards from 1 BH to 1 AH"],
|
||||
],
|
||||
[
|
||||
bh2, ah2,
|
||||
[2, 1, 0, 0, "2y 1mo from 2 BH Dec to 2 AH Jan"],
|
||||
[0, 25, 0, 0, "25mo from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
[
|
||||
ah2, bh2,
|
||||
[-2, -1, 0, 0, "-2y -1mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
[0, -25, 0, 0, "-25mo backwards from 2 BH Dec to 2 AH Jan"],
|
||||
],
|
||||
];
|
||||
|
||||
for (const [one, two, yearsTest, monthsTest] of tests) {
|
||||
let [years, months, weeks, days, descr] = yearsTest;
|
||||
let result = one.until(two, { largestUnit: "years" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
[years, months, weeks, days, descr] = monthsTest;
|
||||
result = one.until(two, { largestUnit: "months" });
|
||||
TemporalHelpers.assertDuration(result, years, months, weeks, days, 0, 0, 0, 0, 0, 0, descr);
|
||||
|
||||
const oneISO = one.withCalendar("iso8601");
|
||||
const twoISO = two.withCalendar("iso8601");
|
||||
|
||||
const resultWeeks = one.until(two, { largestUnit: "weeks" });
|
||||
const resultWeeksISO = oneISO.until(twoISO, { largestUnit: "weeks" });
|
||||
TemporalHelpers.assertDurationsEqual(resultWeeks, resultWeeksISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit weeks`);
|
||||
|
||||
const resultDays = one.until(two);
|
||||
const resultDaysISO = oneISO.until(twoISO);
|
||||
TemporalHelpers.assertDurationsEqual(resultDays, resultDaysISO,
|
||||
`${one.year}-${one.monthCode}-${one.day} : ${two.year}-${two.monthCode}-${two.day} largestUnit days`);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user