// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-temporal.plaindatetime.prototype.until description: Rounding for roundingIncrement option info: | ToTemporalRoundingIncrement ( _normalizedOptions_ ) 1. Let _increment_ be ? GetOption(_normalizedOptions_, *"roundingIncrement"*, *"number"*, *undefined*, *1*𝔽). 2. If _increment_ is not finite, throw a *RangeError* exception. 3. Let _integerIncrement_ be truncate(ℝ(_increment_)). 4. If _integerIncrement_ < 1 or _integerIncrement_ > 109, throw a *RangeError* exception. 5. Return _integerIncrement_. includes: [temporalHelpers.js] features: [Temporal] ---*/ const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0); const later = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 5); const result = earlier.until(later, { roundingIncrement: 2.5, roundingMode: "trunc" }); TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, "roundingIncrement 2.5 truncates to 2"); const result2 = earlier.until(later, { smallestUnit: "days", roundingIncrement: 1e9 + 0.5, roundingMode: "expand" }); TemporalHelpers.assertDuration(result2, 0, 0, 0, 1e9, 0, 0, 0, 0, 0, 0, "roundingIncrement 1e9 + 0.5 truncates to 1e9"); reportCompare(0, 0);