start-of-primary-calendar-era.js (1562B)
1 // |reftest| skip-if(!this.hasOwnProperty("Temporal")||!this.hasOwnProperty("Intl")) 2 3 const calendars = { 4 iso8601: "0001-01-01", 5 buddhist: "-000542-01-01", 6 chinese: "0001-02-10", 7 coptic: "0284-08-29", 8 dangi: "0001-02-10", 9 ethiopic: "0008-08-27", 10 ethioaa: "-005492-07-17", 11 gregory: "0001-01-01", 12 hebrew: "-003760-09-07", 13 indian: "0079-03-22", 14 "islamic-civil": "0622-07-19", 15 "islamic-tbla": "0622-07-18", 16 "islamic-umalqura": "0622-07-19", 17 japanese: "0001-01-01", 18 persian: "0622-03-21", 19 roc: "1912-01-01", 20 }; 21 22 assertEqArray( 23 Intl.supportedValuesOf("calendar").sort(), 24 Object.keys(calendars).sort() 25 ); 26 27 // See bug 1950425. 28 const calendarsNotEnabledInRelease = [ 29 "islamic-umalqura", 30 ]; 31 assertEq(calendarsNotEnabledInRelease.every(c => c in calendars), true); 32 33 for (let [calendar, value] of Object.entries(calendars)) { 34 if (calendarsNotEnabledInRelease.includes(calendar)) { 35 continue; 36 } 37 38 // Ensure year 1 matches the expected date. 39 let yearOne = Temporal.PlainDate.from({calendar, year: 1, month: 1, day: 1}); 40 let expected = Temporal.PlainDate.from(value).withCalendar(calendar); 41 assertEq( 42 Temporal.PlainDate.compare(yearOne, expected), 43 0, 44 yearOne.toString(), 45 ); 46 47 // Ensure year 0 is equal to subtracting one year from year 1. 48 let yearZero = Temporal.PlainDate.from({calendar, year: 0, month: 1, day: 1}); 49 assertEq( 50 Temporal.PlainDate.compare(yearZero, yearOne.subtract("P1Y")), 51 0, 52 yearZero.toString(), 53 ); 54 } 55 56 if (typeof reportCompare === "function") 57 reportCompare(true, true);