Skip to content

Commit b04090d

Browse files
jessealamaptomato
andcommitted
Intl Era Monthcode: Years addition for ethiopic calendar
Co-Authored-By: Philip Chimento <[email protected]>
1 parent 8085d56 commit b04090d

File tree

6 files changed

+294
-0
lines changed

6 files changed

+294
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindate.prototype.add
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(5);
13+
const duration5n = new Temporal.Duration(-5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options);
18+
TemporalHelpers.assertPlainDate(
19+
date1.add(new Temporal.Duration(1)),
20+
1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options);
25+
TemporalHelpers.assertPlainDate(
26+
date2.add(duration5),
27+
2005, 6, "M06", 15, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options);
32+
TemporalHelpers.assertPlainDate(
33+
date3.add(duration5),
34+
-45, 7, "M07", 12, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDate(
39+
date2.add(duration5n),
40+
1995, 6, "M06", 15, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options);
45+
TemporalHelpers.assertPlainDate(
46+
date4.add(duration5n),
47+
0, 1, "M01", 1, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindate.prototype.subtract
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(-5);
13+
const duration5n = new Temporal.Duration(5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar }, options);
18+
TemporalHelpers.assertPlainDate(
19+
date1.subtract(new Temporal.Duration(-1)),
20+
1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar }, options);
25+
TemporalHelpers.assertPlainDate(
26+
date2.subtract(duration5),
27+
2005, 6, "M06", 15, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar }, options);
32+
TemporalHelpers.assertPlainDate(
33+
date3.subtract(duration5),
34+
-45, 7, "M07", 12, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDate(
39+
date2.subtract(duration5n),
40+
1995, 6, "M06", 15, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.PlainDate.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, calendar }, options);
45+
TemporalHelpers.assertPlainDate(
46+
date4.subtract(duration5n),
47+
0, 1, "M01", 1, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindatetime.prototype.add
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(5);
13+
const duration5n = new Temporal.Duration(-5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.add(new Temporal.Duration(1)),
20+
1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.add(duration5),
27+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.add(duration5),
34+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDateTime(
39+
date2.add(duration5n),
40+
1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
45+
TemporalHelpers.assertPlainDateTime(
46+
date4.add(duration5n),
47+
0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindatetime.prototype.subtract
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(-5);
13+
const duration5n = new Temporal.Duration(5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.subtract(new Temporal.Duration(-1)),
20+
1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.subtract(duration5),
27+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.subtract(duration5),
34+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDateTime(
39+
date2.subtract(duration5n),
40+
1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.PlainDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar }, options);
45+
TemporalHelpers.assertPlainDateTime(
46+
date4.subtract(duration5n),
47+
0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.zoneddatetime.prototype.add
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(5);
13+
const duration5n = new Temporal.Duration(-5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.add(new Temporal.Duration(1)).toPlainDateTime(),
20+
1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.add(duration5).toPlainDateTime(),
27+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.add(duration5).toPlainDateTime(),
34+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDateTime(
39+
date2.add(duration5n).toPlainDateTime(),
40+
1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
45+
TemporalHelpers.assertPlainDateTime(
46+
date4.add(duration5n).toPlainDateTime(),
47+
0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.zoneddatetime.prototype.subtract
6+
description: >
7+
Adding years works correctly across era boundaries in calendars with eras
8+
includes: [temporalHelpers.js]
9+
features: [Temporal, Intl.Era-monthcode]
10+
---*/
11+
12+
const duration5 = new Temporal.Duration(-5);
13+
const duration5n = new Temporal.Duration(5);
14+
const calendar = "ethiopic";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.subtract(new Temporal.Duration(-1)).toPlainDateTime(),
20+
1, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
21+
"am", 1
22+
);
23+
24+
const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.subtract(duration5).toPlainDateTime(),
27+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
28+
"am", 2005
29+
);
30+
31+
const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.subtract(duration5).toPlainDateTime(),
34+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
35+
"aa", 5455
36+
);
37+
38+
TemporalHelpers.assertPlainDateTime(
39+
date2.subtract(duration5n).toPlainDateTime(),
40+
1995, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 5 years within incarnation era",
41+
"am", 1995
42+
);
43+
44+
const date4 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 5, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
45+
TemporalHelpers.assertPlainDateTime(
46+
date4.subtract(duration5n).toPlainDateTime(),
47+
0, 1, "M01", 1, 12, 34, 0, 0, 0, 0, "Subtracting 5 years from year 5 lands in last year of Amete Alem era, arithmetic year 0",
48+
"aa", 5500
49+
);

0 commit comments

Comments
 (0)