@@ -10,22 +10,28 @@ features: [Temporal]
10
10
11
11
const result1 = Temporal . PlainMonthDay . from ( { year : 2021 , monthCode : "M02" , day : 29 , calendar : "gregory" } ) ;
12
12
TemporalHelpers . assertPlainMonthDay (
13
- result1 , "M02" , 29 ,
14
- "year is ignored and reference year should be 1972 if monthCode is given " ,
13
+ result1 , "M02" , 28 ,
14
+ "year and monthCode determine if calendar date exists, but reference year should be 1972" ,
15
15
1972
16
16
) ;
17
17
18
18
const result2 = Temporal . PlainMonthDay . from ( { year : 2021 , month : 2 , day : 29 , calendar : "gregory" } , { overflow : "constrain" } ) ;
19
19
TemporalHelpers . assertPlainMonthDay (
20
20
result2 , "M02" , 28 ,
21
- "if monthCode is not given, year is used to determine if calendar date exists, but reference year should still be 1972" ,
21
+ "year and month determine if calendar date exists, but reference year should be 1972" ,
22
22
1972
23
23
) ;
24
24
25
+ assert . throws (
26
+ RangeError ,
27
+ ( ) => Temporal . PlainMonthDay . from ( { year : 2021 , monthCode : "M02" , day : 29 , calendar : "gregory" } , { overflow : "reject" } ) ,
28
+ "RangeError thrown if monthCode and day does not exist in given year and overflow is reject"
29
+ ) ;
30
+
25
31
assert . throws (
26
32
RangeError ,
27
33
( ) => Temporal . PlainMonthDay . from ( { year : 2021 , month : 2 , day : 29 , calendar : "gregory" } , { overflow : "reject" } ) ,
28
- "RangeError thrown if calendar date does not exist in given year and overflow is reject"
34
+ "RangeError thrown if month and day does not exist in given year and overflow is reject"
29
35
) ;
30
36
31
37
const result3 = Temporal . PlainMonthDay . from ( { monthCode : "M01" , day : 1 , calendar : "hebrew" } ) ;
@@ -44,28 +50,41 @@ TemporalHelpers.assertPlainMonthDay(
44
50
45
51
const result5 = Temporal . PlainMonthDay . from ( { year : 5781 , monthCode : "M02" , day : 30 , calendar : "hebrew" } ) ;
46
52
TemporalHelpers . assertPlainMonthDay (
47
- result5 , "M02" , 30 ,
48
- "year is ignored if monthCode is given (Cheshvan 5781 has 29 days)" ,
49
- 1971
53
+ result5 , "M02" , 29 ,
54
+ "year and monthCode determine if calendar date exists, and reference year must agree (Cheshvan 5781 has 29 days)" ,
55
+ 1972
50
56
) ;
51
57
52
58
const result6 = Temporal . PlainMonthDay . from ( { year : 5781 , month : 2 , day : 30 , calendar : "hebrew" } , { overflow : "constrain" } ) ;
53
59
TemporalHelpers . assertPlainMonthDay (
54
60
result6 , "M02" , 29 ,
55
- "if monthCode is not given, year is used to determine if calendar date exists, but reference year still correct " ,
61
+ "year and month determine if calendar date exists, and reference year must agree (Cheshvan 5781 has 29 days) " ,
56
62
1972
57
63
) ;
58
64
65
+ const result7 = Temporal . PlainMonthDay . from ( { monthCode : "M02" , day : 30 , calendar : "hebrew" } ) ;
66
+ TemporalHelpers . assertPlainMonthDay (
67
+ result7 , "M02" , 30 ,
68
+ "reference year must be the latest ISO year at or before 1972 that includes monthCode and day (Cheshvan 5781 has 29 days)" ,
69
+ 1971
70
+ ) ;
71
+
72
+ assert . throws (
73
+ RangeError ,
74
+ ( ) => Temporal . PlainMonthDay . from ( { year : 5781 , monthCode : "M02" , day : 30 , calendar : "hebrew" } , { overflow : "reject" } ) ,
75
+ "RangeError thrown if monthCode and day does not exist in given year and overflow is reject"
76
+ ) ;
77
+
59
78
assert . throws (
60
79
RangeError ,
61
80
( ) => Temporal . PlainMonthDay . from ( { year : 5781 , month : 2 , day : 30 , calendar : "hebrew" } , { overflow : "reject" } ) ,
62
- "RangeError thrown if calendar date does not exist in given year and overflow is reject"
81
+ "RangeError thrown if month and day does not exist in given year and overflow is reject"
63
82
) ;
64
83
65
- const result7 = Temporal . PlainMonthDay . from ( { monthCode : "M04" , day : 26 , calendar : "hebrew" } ) ;
84
+ const result8 = Temporal . PlainMonthDay . from ( { monthCode : "M04" , day : 26 , calendar : "hebrew" } ) ;
66
85
TemporalHelpers . assertPlainMonthDay (
67
- result7 , "M04" , 26 ,
86
+ result8 , "M04" , 26 ,
68
87
"reference date should be the later one, if two options exist in ISO year 1972" ,
69
88
1972
70
89
) ;
71
- assert . sameValue ( result7 . toString ( ) , "1972-12-31[u-ca=hebrew]" , "reference date" ) ;
90
+ assert . sameValue ( result8 . toString ( ) , "1972-12-31[u-ca=hebrew]" , "reference date" ) ;
0 commit comments