Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions test/intl402/Temporal/PlainDate/prototype/add/basic-chinese.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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.add
description: Basic addition and subtraction in the chinese calendar
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/

const calendar = "chinese";
const options = { overflow: "reject" };

// Years

// Months

const duration1 = new Temporal.Duration(0, 1);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).add(duration1),
2019, 12, "M12", 1, "add 1 month, with result in same year"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).add(duration1),
2020, 1, "M01", 1, "add 1 month, with result in next year"
);

// Weeks

const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(months2weeks3),
2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(months2weeks3),
2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year"
);

// Days

const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(days10),
2021, 1, "M01", 11, "add 10 days, ending in same month"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).add(days10),
2021, 2, "M02", 10, "add 10 days, ending in following month"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(days10),
2022, 1, "M01", 10, "add 10 days, ending in following year"
);
61 changes: 61 additions & 0 deletions test/intl402/Temporal/PlainDate/prototype/add/basic-dangi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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.add
description: Basic addition and subtraction in the dangi calendar
features: [Temporal, Intl.Era-monthcode]
includes: [temporalHelpers.js]
---*/

const calendar = "dangi";
const options = { overflow: "reject" };

// Years

// Months

const duration1 = new Temporal.Duration(0, 1);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2019, monthCode: "M11", day: 1, calendar }, options).add(duration1),
2019, 12, "M12", 1, "add 1 month, with result in same year"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2019, monthCode: "M12", day: 1, calendar }, options).add(duration1),
2020, 1, "M01", 1, "add 1 month, with result in next year"
);

// Weeks

const months2weeks3 = new Temporal.Duration(0, /* months = */ 2, /* weeks = */ 3);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(months2weeks3),
2021, 3, "M03", 22, "add 2 months 3 weeks from non-leap day/month, ending in same year"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(months2weeks3),
2022, 3, "M03", 21, "add 2 months 3 weeks from end of year to next year"
);

// Days

const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 1, calendar }, options).add(days10),
2021, 1, "M01", 11, "add 10 days, ending in same month"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M01", day: 29, calendar }, options).add(days10),
2021, 2, "M02", 10, "add 10 days, ending in following month"
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 2021, monthCode: "M12", day: 29, calendar }, options).add(days10),
2022, 1, "M01", 10, "add 10 days, ending in following year"
);
27 changes: 27 additions & 0 deletions test/intl402/Temporal/PlainDate/prototype/add/basic-hebrew.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.add
description: Basic addition and subtraction in the hebrew calendar
features: [Temporal]
includes: [temporalHelpers.js]
---*/

const calendar = "hebrew";
const options = { overflow: "reject" };

// Years

// Months

// Weeks

// Days

const days10 = new Temporal.Duration(0, 0, 0, /* days = */ 10);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 5785, monthCode: "M01", day: 1, calendar }, options).add(days10),
5785, 1, "M01", 11, "adding 10 days", "am", 5785
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.add
description: Basic addition and subtraction in the islamic-civil calendar
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/

const calendar = "islamic-civil";
const options = { overflow: "reject" };

// Years

// Months

const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options);
TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 8)),
1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 11)),
1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 12)),
1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)),
1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)),
1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)),
1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)),
1408, 5, "M05", 1, "Adding a large number of months",
"ah", 1408
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)),
1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)),
1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444",
"ah", 1444
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)),
1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444",
"ah", 1444
);

// Weeks

// Days
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.add
description: Basic addition and subtraction in the islamic-tbla calendar
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/

const calendar = "islamic-tbla";
const options = { overflow: "reject" };

// Years

// Months

const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options);
TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 8)),
1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 11)),
1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 12)),
1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)),
1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)),
1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)),
1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)),
1408, 5, "M05", 1, "Adding a large number of months",
"ah", 1408
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)),
1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)),
1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444",
"ah", 1444
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)),
1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444",
"ah", 1444
);

// Weeks

// Days
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.add
description: Basic addition and subtraction in the islamic-umalqura calendar
includes: [temporalHelpers.js]
features: [Temporal, Intl.Era-monthcode]
---*/

const calendar = "islamic-umalqura";
const options = { overflow: "reject" };

// Years

// Months

const date1 = Temporal.PlainDate.from({ year: 1445, monthCode: "M01", day: 1, calendar }, options);
TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 8)),
1445, 9, "M09", 1, "Adding 8 months to Muharram 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 11)),
1445, 12, "M12", 1, "Adding 11 months to Muharram 1445 lands in Dhu al-Hijjah",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
date1.add(new Temporal.Duration(0, 12)),
1446, 1, "M01", 1, "Adding 12 months to Muharram 1445 lands in Muharram 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 15, calendar }).add(new Temporal.Duration(0, 13)),
1446, 7, "M07", 15, "Adding 13 months to Jumada II 1445 lands in Rajab 1446",
"ah", 1446
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M03", day: 15, calendar }, options).add(new Temporal.Duration(0, 6)),
1445, 9, "M09", 15, "Adding 6 months to Rabi I 1445 lands in Ramadan",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1444, monthCode: "M10", day: 1, calendar }).add(new Temporal.Duration(0, 5)),
1445, 3, "M03", 1, "Adding 5 months to Shawwal 1444 crosses to 1445",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1400, monthCode: "M01", day: 1, calendar }).add(new Temporal.Duration(0, 100)),
1408, 5, "M05", 1, "Adding a large number of months",
"ah", 1408
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M09", day: 1, calendar }, options).add(new Temporal.Duration(0, -8)),
1445, 1, "M01", 1, "Subtracting 8 months from Ramadan 1445 lands in Muharram",
"ah", 1445
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M06", day: 1, calendar }, options).add(new Temporal.Duration(0, -12)),
1444, 6, "M06", 1, "Subtracting 12 months from Jumada II 1445 lands in Jumada II 1444",
"ah", 1444
);

TemporalHelpers.assertPlainDate(
Temporal.PlainDate.from({ year: 1445, monthCode: "M02", day: 15, calendar }, options).add(new Temporal.Duration(0, -5)),
1444, 9, "M09", 15, "Subtracting 5 months from Safar 1445 crosses to Ramadan 1444",
"ah", 1444
);

// Weeks

// Days
Loading