constrain-day-hebrew.js (2141B)
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.plaindatetime.prototype.from 7 description: Constraining the day at end of month (hebrew calendar) 8 includes: [temporalHelpers.js] 9 features: [Temporal, Intl.Era-monthcode] 10 ---*/ 11 12 const calendar = "hebrew"; 13 const options = { overflow: "reject" }; 14 15 // Cheshvan and Kislev (02, 03) have 29 or 30 days, independent of leap years. 16 // Deficient - Cheshvan and Kislev have 29 days 17 // Regular - Cheshvan has 29 days, Kislev 30 18 // Complete - Cheshvan and Kislev have 30 days 19 // 20 // 5781 - a recent deficient year 21 // 5782 - a recent regular year 22 23 TemporalHelpers.assertPlainDateTime( 24 Temporal.PlainDateTime.from({ year: 5781, monthCode: "M03", day: 30, hour: 12, minute: 34, calendar }), 25 5781, 3, "M03", 29, 12, 34, 0, 0, 0, 0, "Kislev constrains to 29 in deficient year", 26 "am", 5781); 27 assert.throws(RangeError, function () { 28 Temporal.PlainDateTime.from({ year: 5781, monthCode: "M03", day: 30, hour: 12, minute: 34, calendar }, options); 29 }, "Kislev rejects 30 in deficient year"); 30 31 TemporalHelpers.assertPlainDateTime( 32 Temporal.PlainDateTime.from({ year: 5782, monthCode: "M02", day: 30, hour: 12, minute: 34, calendar }), 33 5782, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Cheshvan constrains to 29 in regular year", 34 "am", 5782); 35 assert.throws(RangeError, function () { 36 Temporal.PlainDateTime.from({ year: 5782, monthCode: "M02", day: 30, hour: 12, minute: 34, calendar }, options); 37 }, "Cheshvan rejects 30 in regular year"); 38 39 TemporalHelpers.assertPlainDateTime( 40 Temporal.PlainDateTime.from({ year: 5781, monthCode: "M02", day: 30, hour: 12, minute: 34, calendar }), 41 5781, 2, "M02", 29, 12, 34, 0, 0, 0, 0, "Cheshvan constrains to 29 in deficient year", 42 "am", 5781); 43 assert.throws(RangeError, function () { 44 Temporal.PlainDateTime.from({ year: 5781, monthCode: "M02", day: 30, hour: 12, minute: 34, calendar }, options); 45 }, "Cheshvan rejects 30 in deficient year"); 46 47 reportCompare(0, 0);