disambiguation-undefined.js (1633B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2021 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.zoneddatetime.from 7 description: Fallback value for disambiguation option 8 info: | 9 sec-getoption step 3: 10 3. If _value_ is *undefined*, return _fallback_. 11 sec-temporal-totemporaldisambiguation step 1: 12 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). 13 sec-temporal-totemporalzoneddatetime step 5: 14 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). 15 sec-temporal.zoneddatetime.from step 2: 16 2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then 17 ... 18 d. Return ... 19 3. Return ? ToTemporalZonedDateTime(_item_, _options_). 20 features: [Temporal] 21 ---*/ 22 23 const springForwardFields = { timeZone: "America/Vancouver", year: 2000, month: 4, day: 2, hour: 2, minute: 30 }; 24 const fallBackFields = { timeZone: "America/Vancouver", year: 2000, month: 10, day: 29, hour: 1, minute: 30 }; 25 26 [ 27 [springForwardFields, 954671400_000_000_000n], 28 [fallBackFields, 972808200_000_000_000n], 29 ].forEach(([fields, expected]) => { 30 const explicit = Temporal.ZonedDateTime.from(fields, { disambiguation: undefined }); 31 assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible (later)"); 32 33 // See options-undefined.js for {} 34 }); 35 36 reportCompare(0, 0);