reference-day-japanese.js (1632B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2023 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.calendar.prototype.calendaryearmonthfromfields 7 description: > 8 Reference ISO day is chosen to be the first of the calendar month 9 See https://github.com/tc39/proposal-temporal/issues/3150 for more context. 10 info: | 11 1. Let _firstDayIndex_ be the 1-based index of the first day of the month described by _fields_ (i.e., 1 unless the month's first day is skipped by this calendar.) 12 2. Set _fields_.[[Day]] to _firstDayIndex_. 13 3. Perform ? CalendarResolveFields(_calendar_, _fields_, ~year-month~). 14 includes: [temporalHelpers.js] 15 features: [Temporal] 16 ---*/ 17 18 const result1 = Temporal.PlainYearMonth.from({calendar: "japanese", era: "heisei", eraYear: 1, month: 1}); 19 TemporalHelpers.assertPlainYearMonth( 20 result1, 21 1989, 1, "M01", 22 "era is corrected based on reference day (Showa begins on January 8)", 23 "showa", 64 24 ); 25 26 const result2 = Temporal.PlainYearMonth.from({calendar: "japanese", era: "showa", eraYear: 1, month: 12}); 27 TemporalHelpers.assertPlainYearMonth( 28 result2, 29 1926, 12, "M12", 30 "era is corrected based on reference day (TaishÅ begins on December 25)", 31 "taisho", 15 32 ); 33 34 const result3 = Temporal.PlainYearMonth.from({calendar: "japanese", era: "taisho", eraYear: 1, month: 7}); 35 TemporalHelpers.assertPlainYearMonth( 36 result3, 37 1912, 7, "M07", 38 "era is corrected based on reference day (Meiji begins on July 30)", 39 "meiji", 45 40 ); 41 42 reportCompare(0, 0);