Skip to content

Commit 6309fb5

Browse files
jessealamaptomato
andcommitted
Intl Era Monthcode: Era boundary tests for roc calendar
Co-Authored-By: Philip Chimento <[email protected]>
1 parent 6a7f6f4 commit 6309fb5

File tree

6 files changed

+378
-0
lines changed

6 files changed

+378
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(1);
13+
const duration1n = new Temporal.Duration(-1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDate.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, calendar }, options);
18+
TemporalHelpers.assertPlainDate(
19+
date1.add(duration1),
20+
0, 6, "M06", 15, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.PlainDate.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
25+
TemporalHelpers.assertPlainDate(
26+
date2.add(duration1),
27+
1, 6, "M06", 15, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.PlainDate.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
32+
TemporalHelpers.assertPlainDate(
33+
date3.add(duration1),
34+
2, 6, "M06", 15, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.PlainDate.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, calendar }, options);
39+
TemporalHelpers.assertPlainDate(
40+
date4.add(new Temporal.Duration(10)),
41+
6, 3, "M03", 1, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.PlainDate.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
46+
TemporalHelpers.assertPlainDate(
47+
date5.add(duration1n),
48+
4, 6, "M06", 15, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDate(
53+
date3.add(duration1n),
54+
0, 6, "M06", 15, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.PlainDate.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, calendar }, options);
59+
TemporalHelpers.assertPlainDate(
60+
date6.add(new Temporal.Duration(-15)),
61+
-5, 3, "M03", 1, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(-1);
13+
const duration1n = new Temporal.Duration(1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDate.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, calendar }, options);
18+
TemporalHelpers.assertPlainDate(
19+
date1.subtract(duration1),
20+
0, 6, "M06", 15, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.PlainDate.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
25+
TemporalHelpers.assertPlainDate(
26+
date2.subtract(duration1),
27+
1, 6, "M06", 15, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.PlainDate.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, calendar }, options);
32+
TemporalHelpers.assertPlainDate(
33+
date3.subtract(duration1),
34+
2, 6, "M06", 15, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.PlainDate.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, calendar }, options);
39+
TemporalHelpers.assertPlainDate(
40+
date4.subtract(new Temporal.Duration(-10)),
41+
6, 3, "M03", 1, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.PlainDate.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, calendar }, options);
46+
TemporalHelpers.assertPlainDate(
47+
date5.subtract(duration1n),
48+
4, 6, "M06", 15, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDate(
53+
date3.subtract(duration1n),
54+
0, 6, "M06", 15, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.PlainDate.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, calendar }, options);
59+
TemporalHelpers.assertPlainDate(
60+
date6.subtract(new Temporal.Duration(15)),
61+
-5, 3, "M03", 1, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(1);
13+
const duration1n = new Temporal.Duration(-1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.add(duration1),
20+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.add(duration1),
27+
1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.add(duration1),
34+
2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
39+
TemporalHelpers.assertPlainDateTime(
40+
date4.add(new Temporal.Duration(10)),
41+
6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
46+
TemporalHelpers.assertPlainDateTime(
47+
date5.add(duration1n),
48+
4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDateTime(
53+
date3.add(duration1n),
54+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
59+
TemporalHelpers.assertPlainDateTime(
60+
date6.add(new Temporal.Duration(-15)),
61+
-5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(-1);
13+
const duration1n = new Temporal.Duration(1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.subtract(duration1),
20+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.subtract(duration1),
27+
1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.subtract(duration1),
34+
2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.PlainDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
39+
TemporalHelpers.assertPlainDateTime(
40+
date4.subtract(new Temporal.Duration(-10)),
41+
6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, calendar }, options);
46+
TemporalHelpers.assertPlainDateTime(
47+
date5.subtract(duration1n),
48+
4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDateTime(
53+
date3.subtract(duration1n),
54+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.PlainDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, calendar }, options);
59+
TemporalHelpers.assertPlainDateTime(
60+
date6.subtract(new Temporal.Duration(15)),
61+
-5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(1);
13+
const duration1n = new Temporal.Duration(-1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.add(duration1).toPlainDateTime(),
20+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.add(duration1).toPlainDateTime(),
27+
1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.add(duration1).toPlainDateTime(),
34+
2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
39+
TemporalHelpers.assertPlainDateTime(
40+
date4.add(new Temporal.Duration(10)).toPlainDateTime(),
41+
6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
46+
TemporalHelpers.assertPlainDateTime(
47+
date5.add(duration1n).toPlainDateTime(),
48+
4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDateTime(
53+
date3.add(duration1n).toPlainDateTime(),
54+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
59+
TemporalHelpers.assertPlainDateTime(
60+
date6.add(new Temporal.Duration(-15)).toPlainDateTime(),
61+
-5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 duration1 = new Temporal.Duration(-1);
13+
const duration1n = new Temporal.Duration(1);
14+
const calendar = "roc";
15+
const options = { overflow: "reject" };
16+
17+
const date1 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 2, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
18+
TemporalHelpers.assertPlainDateTime(
19+
date1.subtract(duration1).toPlainDateTime(),
20+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 2 BROC lands in 1 BROC (counts backwards)",
21+
"broc", 1
22+
);
23+
24+
const date2 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
25+
TemporalHelpers.assertPlainDateTime(
26+
date2.subtract(duration1).toPlainDateTime(),
27+
1, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 BROC lands in 1 ROC (no year zero)",
28+
"roc", 1
29+
);
30+
31+
const date3 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 1, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
32+
TemporalHelpers.assertPlainDateTime(
33+
date3.subtract(duration1).toPlainDateTime(),
34+
2, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Adding 1 year to 1 ROC lands in 2 ROC",
35+
"roc", 2
36+
);
37+
38+
const date4 = Temporal.ZonedDateTime.from({ era: "broc", eraYear: 5, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
39+
TemporalHelpers.assertPlainDateTime(
40+
date4.subtract(new Temporal.Duration(-10)).toPlainDateTime(),
41+
6, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Adding 10 years to 5 BROC lands in 6 ROC (no year zero)",
42+
"roc", 6
43+
);
44+
45+
const date5 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 5, monthCode: "M06", day: 15, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
46+
TemporalHelpers.assertPlainDateTime(
47+
date5.subtract(duration1n).toPlainDateTime(),
48+
4, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 5 lands in ROC 4",
49+
"roc", 4
50+
);
51+
52+
TemporalHelpers.assertPlainDateTime(
53+
date3.subtract(duration1n).toPlainDateTime(),
54+
0, 6, "M06", 15, 12, 34, 0, 0, 0, 0, "Subtracting 1 year from ROC 1 lands in BROC 1",
55+
"broc", 1
56+
);
57+
58+
const date6 = Temporal.ZonedDateTime.from({ era: "roc", eraYear: 10, monthCode: "M03", day: 1, hour: 12, minute: 34, timeZone: "UTC", calendar }, options);
59+
TemporalHelpers.assertPlainDateTime(
60+
date6.subtract(new Temporal.Duration(15)).toPlainDateTime(),
61+
-5, 3, "M03", 1, 12, 34, 0, 0, 0, 0, "Subtracting 15 years from ROC 10 lands in BROC 6",
62+
"broc", 6
63+
);

0 commit comments

Comments
 (0)