roundtrip-from-iso.js (1238B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2025 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.plaindate.from 7 description: > 8 Check that various dates created from calculated properties have the expected 9 properties 10 includes: [temporalHelpers.js] 11 features: [Temporal, Intl.Era-monthcode] 12 ---*/ 13 14 const year2000 = new Temporal.PlainDate(2000, 1, 1); 15 testRoundtrip(year2000); 16 const year1 = new Temporal.PlainDate(1, 1, 1); 17 testRoundtrip(year1); 18 19 function testRoundtrip(date) { 20 const dateFromYearMonth = Temporal.PlainDate.from({ 21 year: date.year, 22 month: date.month, 23 day: date.day, 24 }); 25 TemporalHelpers.assertPlainDate( 26 dateFromYearMonth, 27 date.year, date.month, date.monthCode, date.day, 28 `${date} - created from year and month`); 29 30 const dateFromYearMonthCode = Temporal.PlainDate.from({ 31 year: date.year, 32 monthCode: date.monthCode, 33 day: date.day, 34 }); 35 TemporalHelpers.assertPlainDate( 36 dateFromYearMonthCode, 37 date.year, date.month, date.monthCode, date.day, 38 `${date} - created from year and month code`); 39 } 40 41 reportCompare(0, 0);