reference-dates-chinese-calendar.js (2780B)
1 // |reftest| skip-if(!this.hasOwnProperty("Temporal")) 2 3 const calendar = "chinese"; 4 5 // The Chinese calendar has 29-30 days per month. 6 const tests = [ 7 { 8 day: 29, 9 leapMonth: false, 10 expected: [ 11 "1972-03-14[u-ca=chinese]", 12 "1972-04-12[u-ca=chinese]", 13 "1972-05-12[u-ca=chinese]", 14 "1972-06-10[u-ca=chinese]", 15 "1972-07-09[u-ca=chinese]", 16 "1972-08-08[u-ca=chinese]", 17 "1972-09-06[u-ca=chinese]", 18 "1972-10-06[u-ca=chinese]", 19 "1972-11-04[u-ca=chinese]", 20 "1972-12-04[u-ca=chinese]", 21 "1972-01-15[u-ca=chinese]", 22 "1972-02-13[u-ca=chinese]", 23 ], 24 }, 25 { 26 day: 29, 27 leapMonth: true, 28 expected: [ 29 "1651-03-20[u-ca=chinese]", 30 "1947-04-20[u-ca=chinese]", 31 "1966-05-19[u-ca=chinese]", 32 "1963-06-20[u-ca=chinese]", 33 "1971-07-21[u-ca=chinese]", 34 "1960-08-21[u-ca=chinese]", 35 "1968-09-21[u-ca=chinese]", 36 "1957-10-22[u-ca=chinese]", 37 "2014-11-21[u-ca=chinese]", 38 "1984-12-21[u-ca=chinese]", 39 "2034-01-19[u-ca=chinese]", 40 "1404-02-19[u-ca=chinese]", 41 ], 42 }, 43 { 44 day: 30, 45 leapMonth: false, 46 expected: [ 47 "1970-03-07[u-ca=chinese]", 48 "1972-04-13[u-ca=chinese]", 49 "1966-04-20[u-ca=chinese]", 50 "1970-06-03[u-ca=chinese]", 51 "1972-07-10[u-ca=chinese]", 52 "1971-08-20[u-ca=chinese]", 53 "1972-09-07[u-ca=chinese]", 54 "1971-10-18[u-ca=chinese]", 55 "1972-11-05[u-ca=chinese]", 56 "1972-12-05[u-ca=chinese]", 57 "1970-01-07[u-ca=chinese]", 58 "1972-02-14[u-ca=chinese]", 59 ], 60 }, 61 { 62 day: 30, 63 leapMonth: true, 64 expected: [ 65 "1461-03-20[u-ca=chinese]", 66 "1765-04-19[u-ca=chinese]", 67 "1955-05-21[u-ca=chinese]", 68 "1944-06-20[u-ca=chinese]", 69 "1952-07-21[u-ca=chinese]", 70 "1941-08-22[u-ca=chinese]", 71 "1938-09-23[u-ca=chinese]", 72 "1718-10-23[u-ca=chinese]", 73 "-005738-11-17[u-ca=chinese]", 74 "-004098-12-19[u-ca=chinese]", 75 "-002172-01-19[u-ca=chinese]", 76 "-000179-02-18[u-ca=chinese]", 77 ], 78 }, 79 ]; 80 81 for (let {day, leapMonth, expected} of tests) { 82 assertEq(expected.length, 12); 83 84 for (let i = 1; i <= 12; ++i) { 85 let expectedToString = expected[i - 1]; 86 87 // Skip over dates which are too far into the past (and therefore are likely 88 // incorrect anyway). This avoids slowing down this test. 89 if (expectedToString.startsWith("-")) { 90 continue; 91 } 92 93 let monthCode = "M" + String(i).padStart(2, "0") + (leapMonth ? "L" : ""); 94 95 let pmd = Temporal.PlainMonthDay.from({calendar, monthCode, day}); 96 assertEq(pmd.monthCode, monthCode); 97 assertEq(pmd.day, day); 98 assertEq(pmd.toString(), expectedToString); 99 } 100 } 101 102 if (typeof reportCompare === "function") 103 reportCompare(true, true);