Skip to content

Commit ddacd2b

Browse files
committed
Split addition-across-lunisolar-leap-months across calendars
Also remove unnecessary check for out-dated Chinese calendar data.
1 parent c2c2384 commit ddacd2b

3 files changed

+96
-93
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal-intl
6+
description: Addition across lunisolar leap months
7+
features: [Temporal]
8+
---*/
9+
10+
const chineseYearOffset = new Temporal.PlainDate(1, 1, 1, "chinese").year;
11+
12+
// Adding years across Chinese leap month
13+
var date = Temporal.PlainDate.from({
14+
year: 2000 + chineseYearOffset,
15+
monthCode: "M08",
16+
day: 2,
17+
calendar: "chinese"
18+
});
19+
var added = date.add({ years: 1 });
20+
assert.sameValue(added.day, date.day);
21+
assert.sameValue(added.monthCode, date.monthCode);
22+
assert.sameValue(added.year, date.year + 1);
23+
24+
// Adding months across Chinese leap month
25+
var date = Temporal.PlainDate.from({
26+
year: 2000 + chineseYearOffset,
27+
monthCode: "M08",
28+
day: 2,
29+
calendar: "chinese"
30+
});
31+
var added = date.add({ months: 13 });
32+
assert.sameValue(added.day, date.day);
33+
assert.sameValue(added.monthCode, date.monthCode);
34+
assert.sameValue(added.year, date.year + 1);
35+
36+
// Adding months and years across Chinese leap month
37+
var date = Temporal.PlainDate.from({
38+
year: 2001 + chineseYearOffset,
39+
monthCode: "M08",
40+
day: 2,
41+
calendar: "chinese"
42+
});
43+
var added = date.add({
44+
years: 1,
45+
months: 12
46+
});
47+
assert.sameValue(added.day, date.day);
48+
assert.sameValue(added.monthCode, date.monthCode);
49+
assert.sameValue(added.year, date.year + 2);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal-intl
6+
description: Addition across lunisolar leap months
7+
features: [Temporal]
8+
---*/
9+
10+
// Adding years across Hebrew leap month
11+
var date = Temporal.PlainDate.from({
12+
year: 5783,
13+
monthCode: "M08",
14+
day: 2,
15+
calendar: "hebrew"
16+
});
17+
var added = date.add({ years: 1 });
18+
assert.sameValue(added.day, date.day);
19+
assert.sameValue(added.monthCode, date.monthCode);
20+
assert.sameValue(added.year, date.year + 1);
21+
22+
// Adding months across Hebrew leap month
23+
var date = Temporal.PlainDate.from({
24+
year: 5783,
25+
monthCode: "M08",
26+
day: 2,
27+
calendar: "hebrew"
28+
});
29+
var added = date.add({ months: 13 });
30+
assert.sameValue(added.day, date.day);
31+
assert.sameValue(added.monthCode, date.monthCode);
32+
assert.sameValue(added.year, date.year + 1);
33+
34+
// Adding months and years across Hebrew leap month
35+
var date = Temporal.PlainDate.from({
36+
year: 5783,
37+
monthCode: "M08",
38+
day: 2,
39+
calendar: "hebrew"
40+
});
41+
var added = date.add({
42+
years: 1,
43+
months: 12
44+
});
45+
assert.sameValue(added.day, date.day);
46+
assert.sameValue(added.monthCode, date.monthCode);
47+
assert.sameValue(added.year, date.year + 2);

test/staging/Intl402/Temporal/old/addition-across-lunisolar-leap-months.js

-93
This file was deleted.

0 commit comments

Comments
 (0)