Skip to content

Commit e7c357c

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

File tree

6 files changed

+210
-0
lines changed

6 files changed

+210
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar });
17+
TemporalHelpers.assertPlainDate(
18+
date1.add(new Temporal.Duration(1)),
19+
1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar });
24+
TemporalHelpers.assertPlainDate(
25+
date2.add(duration5),
26+
2005, 6, "M06", 15, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar });
31+
TemporalHelpers.assertPlainDate(
32+
date3.add(duration5),
33+
-45, 7, "M07", 12, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.PlainDate.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, calendar });
17+
TemporalHelpers.assertPlainDate(
18+
date1.subtract(new Temporal.Duration(-1)),
19+
1, 1, "M01", 1, "Adding 1 year to last year of Amete Alem era lands in year 1 of incarnation era",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.PlainDate.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, calendar });
24+
TemporalHelpers.assertPlainDate(
25+
date2.subtract(duration5),
26+
2005, 6, "M06", 15, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.PlainDate.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, calendar });
31+
TemporalHelpers.assertPlainDate(
32+
date3.subtract(duration5),
33+
-45, 7, "M07", 12, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar });
17+
TemporalHelpers.assertPlainDateTime(
18+
date1.add(new Temporal.Duration(1)),
19+
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",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar });
24+
TemporalHelpers.assertPlainDateTime(
25+
date2.add(duration5),
26+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar });
31+
TemporalHelpers.assertPlainDateTime(
32+
date3.add(duration5),
33+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, calendar });
17+
TemporalHelpers.assertPlainDateTime(
18+
date1.subtract(new Temporal.Duration(-1)),
19+
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",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.PlainDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar });
24+
TemporalHelpers.assertPlainDateTime(
25+
date2.subtract(duration5),
26+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.PlainDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, calendar });
31+
TemporalHelpers.assertPlainDateTime(
32+
date3.subtract(duration5),
33+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar });
17+
TemporalHelpers.assertPlainDateTime(
18+
date1.add(new Temporal.Duration(1)).toPlainDateTime(),
19+
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",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar });
24+
TemporalHelpers.assertPlainDateTime(
25+
date2.add(duration5).toPlainDateTime(),
26+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar });
31+
TemporalHelpers.assertPlainDateTime(
32+
date3.add(duration5).toPlainDateTime(),
33+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 calendar = "ethiopic";
14+
const options = { overflow: "reject" };
15+
16+
const date1 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5500, monthCode: "M01", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar });
17+
TemporalHelpers.assertPlainDateTime(
18+
date1.subtract(new Temporal.Duration(-1)).toPlainDateTime(),
19+
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",
20+
"am", 1
21+
);
22+
23+
const date2 = Temporal.ZonedDateTime.from({ era: "am", eraYear: 2000, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar });
24+
TemporalHelpers.assertPlainDateTime(
25+
date2.subtract(duration5).toPlainDateTime(),
26+
2005, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 5 years within incarnation era",
27+
"am", 2005
28+
);
29+
30+
const date3 = Temporal.ZonedDateTime.from({ era: "aa", eraYear: 5450, monthCode: "M07", day: 12, hour: 12, minute: 34, timeZone: "UTC", calendar });
31+
TemporalHelpers.assertPlainDateTime(
32+
date3.subtract(duration5).toPlainDateTime(),
33+
-45, 7, "M07", 12, 12, 34, 0, 0, 0, 0, "Adding 5 years within Amete Alem era",
34+
"aa", 5455
35+
);

0 commit comments

Comments
 (0)