reference-day.js (1563B)
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.plainyearmonth.from 7 description: Reference ISO day is chosen to be the first of the calendar month 8 info: | 9 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*<sub>𝔽</sub>). 10 e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). 11 includes: [temporalHelpers.js] 12 features: [Temporal] 13 ---*/ 14 15 const result1 = Temporal.PlainYearMonth.from({ year: 2023, monthCode: "M01", day: 13 }); 16 TemporalHelpers.assertPlainYearMonth( 17 result1, 18 2023, 1, "M01", 19 "reference day is 1 even if day is given", 20 /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 21 ); 22 23 const result2 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "constrain" }); 24 TemporalHelpers.assertPlainYearMonth( 25 result2, 26 2021, 2, "M02", 27 "reference day is 1 even if day is out of range (overflow constrain)", 28 /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 29 ); 30 31 const result3 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "reject" }); 32 TemporalHelpers.assertPlainYearMonth( 33 result3, 34 2021, 2, "M02", 35 "reference day is 1 even if day is out of range (overflow reject)", 36 /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 37 ); 38 39 reportCompare(0, 0);