calendar-not-supporting-eras.js (1505B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2024 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: era and eraYear are ignored (for calendars not using eras) 8 includes: [temporalHelpers.js] 9 features: [Temporal, Intl.Era-monthcode] 10 ---*/ 11 12 const result = Temporal.PlainDate.from({ 13 era: "foobar", 14 eraYear: 1, 15 year: 1970, 16 monthCode: "M01", 17 day: 1, 18 calendar: "iso8601", 19 }); 20 TemporalHelpers.assertPlainDate(result, 1970, 1, "M01", 1, 21 "era and eraYear are ignored for calendar not using eras (iso8601)"); 22 23 assert.throws(TypeError, () => Temporal.PlainDate.from({ 24 era: "foobar", 25 eraYear: 1, 26 monthCode: "M01", 27 day: 1, 28 calendar: "iso8601", 29 }), "era and eraYear cannot replace year for calendar not using eras (iso8601)"); 30 31 const resultChinese = Temporal.PlainDate.from({ 32 era: "foobar", 33 eraYear: 1, 34 year: 2025, 35 monthCode: "M01", 36 day: 1, 37 calendar: "chinese", 38 }); 39 TemporalHelpers.assertPlainDate(resultChinese, 2025, 1, "M01", 1, 40 "era and eraYear are ignored for calendar not using eras (Chinese)"); 41 assert.sameValue(resultChinese.calendarId, "chinese"); 42 43 assert.throws(TypeError, () => Temporal.PlainDate.from({ 44 era: "foobar", 45 eraYear: 1, 46 monthCode: "M01", 47 day: 1, 48 calendar: "chinese", 49 }), "era and eraYear cannot replace year for calendar not using eras (Chinese)"); 50 51 reportCompare(0, 0);