| balance-negative-result.js |
---
esid: sec-temporal.duration.prototype.round
description: A negative duration result is balanced correctly by the modulo operation in NanosecondsToDays
info: |
sec-temporal-nanosecondstodays step 6:
6. If Type(_relativeTo_) is not Object or _relativeTo_ does not have an [[InitializedTemporalZonedDateTime]] internal slot, then
a. Return the new Record { ..., [[Nanoseconds]]: abs(_nanoseconds_) modulo _dayLengthNs_ × _sign_, ... }.
sec-temporal-balanceduration step 4:
4. If _largestUnit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then
a. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _relativeTo_).
sec-temporal.duration.prototype.round step 25:
25. Let _result_ be ? BalanceDuration(_balanceResult_.[[Days]], _adjustResult_.[[Hours]], _adjustResult_.[[Minutes]], _adjustResult_.[[Seconds]], _adjustResult_.[[Milliseconds]], _adjustResult_.[[Microseconds]], _adjustResult_.[[Nanoseconds]], _largestUnit_, _relativeTo_).
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1484 |
- |
| balance-subseconds.js |
---
esid: sec-temporal.duration.prototype.round
description: Balancing from subsecond units to seconds happens correctly
includes: [temporalHelpers.js]
features: [Temporal]
--- |
812 |
- |
| balances-days-up-to-both-years-and-months.js |
---
esid: sec-temporal.duration.prototype.round
description: Balances days up to both years and months.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
648 |
- |
| balances-up-to-next-unit-after-rounding.js |
---
esid: sec-temporal.duration.prototype.round
description: Balances up to the next unit after rounding.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
678 |
- |
| balances-up-to-weeks.js |
---
esid: sec-temporal.duration.prototype.round
description: Rounds up to weeks correctly when years and months are present.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2221 |
- |
| blank-duration.js |
---
esid: sec-temporal.duration.prototype.round
description: Behaviour with blank duration
features: [Temporal]
includes: [temporalHelpers.js]
--- |
1709 |
- |
| branding.js |
---
esid: sec-temporal.duration.prototype.round
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
--- |
1190 |
- |
| browser.js |
|
0 |
- |
| bubble-time-unit.js |
---
esid: sec-temporal.duration.prototype.round
description: Rounds relative to a date, bubbling up time units.
info: |
https://github.com/tc39/proposal-temporal/issues/3121
Test case that calls BubbleRelativeDuration with a time unit as largestUnit.
This happens when time units round up and overflow a date unit, and
largestUnit is not "days" or higher, and the rounding is relative to a
PlainDateTime (ZonedDateTime would use Instant semantics in that case.)
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2719 |
- |
| builtin.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Tests that Temporal.Duration.prototype.round
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Built-in functions that are not constructors do not have a "prototype" property unless
otherwise specified in the description of a particular function.
Unless specified otherwise, a built-in object that is callable as a function is a built-in
function object with the characteristics described in 10.3. Unless specified otherwise, the
[[Extensible]] internal slot of a built-in object initially has the value true.
Unless otherwise specified every built-in function and every built-in constructor has the
Function prototype object [...] as the value of its [[Prototype]] internal slot.
features: [Temporal]
--- |
1635 |
- |
| calendar-possibly-required.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo argument required if days = 0 but years/months/weeks non-zero
features: [Temporal]
includes: [temporalHelpers.js]
--- |
3607 |
- |
| calendar-temporal-object.js |
---
esid: sec-temporal.duration.prototype.round
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
info: |
sec-temporal.duration.prototype.round step 19:
19. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_).
sec-temporal-torelativetemporalobject step 4.b:
b. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_).
sec-temporal-gettemporalcalendarwithisodefault step 2:
2. Return ? ToTemporalCalendarWithISODefault(_calendar_).
sec-temporal-totemporalcalendarwithisodefault step 2:
3. Return ? ToTemporalCalendar(_temporalCalendarLike_).
sec-temporal-totemporalcalendar step 1.a:
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
i. Return _temporalCalendarLike_.[[Calendar]].
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
1564 |
- |
| case-where-relativeto-affects-rounding-mode-half-even.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Rare edge case where presence or absence of relativeTo affects the rounding
behaviour of rounding mode halfEven
features: [Temporal]
includes: [temporalHelpers.js]
--- |
1698 |
- |
| days-24-hours.js |
---
esid: sec-temporal.duration.prototype.round
description: Days are 24 hours if relativeTo not given.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
618 |
- |
| does-not-balance-up-to-weeks-if-largest-unit-is-larger-than-weeks.js |
---
esid: sec-temporal.duration.prototype.round
description: Does not balance up to weeks if largestUnit is larger than weeks.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
683 |
- |
| durations-do-not-balance-beyond-largest-unit.js |
---
esid: sec-temporal.duration.prototype.round
description: Durations do not balance beyond their current largest unit by default.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
894 |
- |
| end-of-month-round-up.js |
---
esid: sec-temporal.duration.prototype.round
description: Correctly handle special case where rounding value is at upper bound
info: |
sec-temporal-nudgetocalendarunit:
1. If _progress_ = 1, then
1. Let _roundedUnit_ be abs(_r2_).
1. Else,
1. Let _roundedUnit_ be ApplyUnsignedRoundingMode(abs(_total_), abs(_r1_),
abs(_r2_), _unsignedRoundingMode_).
includes: [temporalHelpers.js]
features: [Temporal]
--- |
961 |
- |
| february-leap-year.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when largestUnit option not one of the allowed string values
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1446 |
- |
| float64-representable-integer.js |
---
esid: sec-temporal.duration.prototype.round
description: Internal representation uses float64-representable integers
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1345 |
- |
| half-expand-is-default.js |
---
esid: sec-temporal.duration.prototype.round
description: halfExpand is the default.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
764 |
- |
| invalid-increments.js |
---
esid: sec-temporal.duration.prototype.round
description: Test various invalid rounding increments.
features: [Temporal]
--- |
2010 |
- |
| largestunit-correct-rebalancing.js |
---
esid: sec-temporal.duration.prototype.round
description: Balancing from hours or smaller to weeks or bigger happens correctly.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1147 |
- |
| largestunit-invalid-string.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when largestUnit option not one of the allowed string values
features: [Temporal]
--- |
579 |
- |
| largestunit-plurals-accepted.js |
---
esid: sec-temporal.duration.prototype.round
description: Plural units are accepted as well for the largestUnit option
includes: [temporalHelpers.js]
features: [Temporal]
--- |
826 |
- |
| largestunit-smallestunit-combinations.js |
---
esid: sec-temporal.duration.prototype.round
description: Test for all combinations of largestUnit and smallestUnit without relativeTo
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2140 |
- |
| largestunit-smallestunit-default.js |
---
esid: sec-temporal.duration.prototype.round
description: assumes a different default for largestUnit if smallestUnit is larger than the default
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2245 |
- |
| largestunit-smallestunit-mismatch.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when smallestUnit is larger than largestUnit
features: [Temporal]
--- |
1019 |
- |
| largestunit-undefined.js |
---
esid: sec-temporal.duration.prototype.round
description: Fallback value for largestUnit option
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1375 |
- |
| largestunit-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: Type conversions for largestUnit option
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
736 |
- |
| length.js |
---
esid: sec-temporal.duration.prototype.round
description: Temporal.Duration.prototype.round.length is 1
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
arguments shown in the subclause headings for the function description. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
«...name») are not included in the default argument count.
Unless otherwise specified, the "length" property of a built-in function object has the
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
--- |
1194 |
- |
| name.js |
---
esid: sec-temporal.duration.prototype.round
description: Temporal.Duration.prototype.round.name is "round".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
is the name that is given to the function in this specification.
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Temporal]
--- |
1032 |
- |
| next-day-out-of-range.js |
---
esid: sec-temporal.zoneddatetime.prototype.hoursinday
description: >
Finding the boundary with the next day may throw if the instance is at the
upper edge of the representable range
features: [Temporal]
--- |
750 |
- |
| not-a-constructor.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Temporal.Duration.prototype.round does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
function.
includes: [isConstructor.js]
features: [Reflect.construct, Temporal]
--- |
920 |
- |
| options-read-before-algorithmic-validation.js |
---
esid: sec-temporal.duration.prototype.round
description: >
All options properties are read and cast before any algorithmic validation
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
2580 |
- |
| options-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: TypeError thrown when options argument is missing or a non-string primitive
features: [BigInt, Symbol, Temporal]
--- |
803 |
- |
| order-of-operations.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Properties on objects passed to round() are accessed in the correct order
when relativeTo is a property bag.
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
7128 |
- |
| out-of-range-when-converting-from-normalized-duration.js |
---
esid: sec-temporal.duration.prototype.round
description: >
When converting the result from normalized duration form, each duration
component is turned into a float64-representable integer
features: [Temporal]
--- |
2627 |
- |
| precision-exact-in-balance-time-duration.js |
---
esid: sec-temporal.duration.prototype.round
description: BalanceTimeDuration computes on exact mathematical values.
includes: [temporalHelpers.js]
features: [BigInt, Temporal]
--- |
2443 |
- |
| precision-exact-in-round-duration.js |
---
esid: sec-temporal.duration.prototype.round
description: >
RoundDuration computes on exact mathematical values.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1368 |
- |
| prop-desc.js |
---
esid: sec-temporal.duration.prototype.round
description: The "round" property of Temporal.Duration.prototype
includes: [propertyHelper.js]
features: [Temporal]
--- |
673 |
- |
| relativeto-argument-propertybag-calendar-invalid-iso-string.js |
---
esid: sec-temporal.duration.prototype.round
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
--- |
864 |
- |
| relativeto-argument-string-calendar-invalid-iso-string.js |
---
esid: sec-temporal.duration.prototype.round
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
--- |
940 |
- |
| relativeto-balances-down-differently-depending-on-relative-date.js |
---
esid: sec-temporal.duration.prototype.round
description: Balances down differently depending on relativeTo.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1214 |
- |
| relativeto-balances-up-differently-depending-on-relative-date.js |
---
esid: sec-temporal.duration.prototype.round
description: Balances up differently depending on relativeTo.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1878 |
- |
| relativeto-casts-relative-date-to-plain-date.js |
---
esid: sec-temporal.duration.prototype.round
description: round() casts relativeTo to PlainDate if possible
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1170 |
- |
| relativeto-date-limits.js |
---
esid: sec-temporal.duration.prototype.round
description: Maximum and minimum dates can be used as relativeTo parameter
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2672 |
- |
| relativeto-days-24-hours-relative-to-plain-date.js |
---
esid: sec-temporal.duration.prototype.round
description: Days are 24 hours if relativeTo is PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
--- |
687 |
- |
| relativeto-days-24-hours-relative-to-zoned-date-time.js |
---
esid: sec-temporal.duration.prototype.round
description: Days are 24 hours if relativeTo is ZonedDateTime and duration encompasses no DST change
includes: [temporalHelpers.js]
features: [Temporal]
--- |
760 |
- |
| relativeto-duration-out-of-range-added-to-relative-date.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when calendar part of duration added to relativeTo is out of range
features: [Temporal]
info: |
RoundDuration:
10.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*).
i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_).
...
11.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*).
i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_).
...
12.a. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*).
b. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_).
UnbalanceDateDurationRelative:
11. Let _yearsMonthsWeeksDuration_ be ! CreateTemporalDuration(_years_, _months_, _weeks_, 0, 0, 0, 0, 0, 0, 0).
12. Let _later_ be ? CalendarDateAdd(_calendaRec_, _plainRelativeTo_, _yearsMonthsWeeksDuration_).
13. Let _yearsMonthsWeeksInDays_ be DaysUntil(_plainRelativeTo_, _later_).
14. Return ? CreateDateDurationRecord(0, 0, 0, _days_ + _yearsMonthsWeeksInDays_).
--- |
3440 |
- |
| relativeto-ignores-incorrect-properties.js |
---
esid: sec-temporal.duration.prototype.round
description: Incorrectly-spelled properties are ignored in relativeTo.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
976 |
- |
| relativeto-infinity-throws-rangeerror.js |
---
description: Throws if any value in the property bag is Infinity or -Infinity
esid: sec-temporal.duration.prototype.round
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
1346 |
- |
| relativeto-largestunit-smallestunit-combinations.js |
---
esid: sec-temporal.duration.prototype.round
description: Test for all combinations of largestUnit and smallestUnit with relativeTo
includes: [temporalHelpers.js]
features: [Temporal]
--- |
4154 |
- |
| relativeto-leap-second.js |
---
esid: sec-temporal.duration.prototype.round
description: Leap second is constrained in both an ISO string and a property bag
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1628 |
- |
| relativeto-no-fractional-minutes-hours.js |
---
esid: sec-temporal.duration.prototype.round
description: Fractional minutes or hours in time string in relativeTo option should throw RangeError
features: [Temporal]
--- |
814 |
- |
| relativeto-not-required-to-round-non-calendar-units.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo is not required to round non-calendar units in durations without calendar units.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1924 |
- |
| relativeto-number.js |
---
esid: sec-temporal.duration.prototype.round
description: A number cannot be used in place of a relativeTo
features: [Temporal]
--- |
722 |
- |
| relativeto-propertybag-calendar-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Appropriate error thrown when relativeTo.calendar cannot be converted to a
calendar object or string
features: [BigInt, Symbol, Temporal]
--- |
1315 |
- |
| relativeto-propertybag-invalid-offset-string.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo property bag with offset property is rejected if offset is in the wrong format
features: [Temporal]
--- |
1140 |
- |
| relativeto-propertybag-no-time-units.js |
---
esid: sec-temporal.duration.prototype.round
description: Missing time units in relativeTo property bag default to 0
includes: [temporalHelpers.js]
features: [Temporal]
--- |
711 |
- |
| relativeto-propertybag-optional-properties.js |
---
esid: sec-temporal.duration.prototype.round
description: >
A property bag missing optional properties is equivalent to a property bag
with all the optional properties having their default values
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1147 |
- |
| relativeto-propertybag-timezone-string-datetime.js |
---
esid: sec-temporal.duration.prototype.round
description: Conversion of ISO date-time strings to time zone IDs
features: [Temporal]
--- |
2218 |
- |
| relativeto-propertybag-timezone-string-leap-second.js |
---
esid: sec-temporal.duration.prototype.round
description: Leap second is a valid ISO string for TimeZone
features: [Temporal]
--- |
917 |
- |
| relativeto-propertybag-timezone-string-year-zero.js |
---
esid: sec-temporal.duration.prototype.round
description: Negative zero, as an extended year, is rejected
features: [Temporal, arrow-function]
--- |
767 |
- |
| relativeto-propertybag-timezone-string.js |
---
esid: sec-temporal.duration.prototype.round
description: Time zone IDs are valid input for a time zone
features: [Temporal]
--- |
637 |
- |
| relativeto-propertybag-timezone-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Appropriate error thrown when argument cannot be converted to a valid string
for time zone
features: [BigInt, Symbol, Temporal]
--- |
1443 |
- |
| relativeto-required-for-rounding-durations-with-calendar-units.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo is required for rounding durations with calendar units
features: [Temporal]
--- |
1174 |
- |
| relativeto-required-properties.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo object must contain at least the required correctly-spelled properties
features: [Temporal]
--- |
861 |
- |
| relativeto-required-to-round-calendar-units.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo is required to round calendar units even in durations without calendar units.
features: [Temporal]
--- |
899 |
- |
| relativeto-rounding-date.js |
---
esid: sec-temporal.duration.prototype.round
description: Test that round() counts the correct number of days when rounding relative to a date.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1748 |
- |
| relativeto-string-invalid.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown if relativeTo is a string with the wrong format
features: [Temporal]
--- |
910 |
- |
| relativeto-string-limits.js |
---
esid: sec-temporal.duration.prototype.round
description: ISO strings at the edges of the representable range
features: [Temporal]
--- |
2205 |
- |
| relativeto-string-wrong-offset.js |
---
esid: sec-temporal.duration.prototype.round
description: Throws if a ZonedDateTime-like relativeTo string has the wrong timezone offset
features: [Temporal]
--- |
891 |
- |
| relativeto-string.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo option accepts ISO date-time strings as argument
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1454 |
- |
| relativeto-sub-minute-offset.js |
---
esid: sec-temporal.duration.prototype.round
description: relativeTo string accepts trailing zeroes in sub-minute UTC offset
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1388 |
- |
| relativeto-undefined-throw-on-calendar-units.js |
---
esid: sec-temporal.duration.prototype.round
description: >
The relativeTo option is required when the Duration contains years, months,
or weeks, and largestUnit is days; or largestUnit is weeks or months
features: [Temporal]
includes: [temporalHelpers.js]
--- |
1440 |
- |
| relativeto-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Appropriate error thrown when relativeTo cannot be converted to a valid
relativeTo string or property bag
features: [BigInt, Symbol, Temporal]
--- |
1615 |
- |
| relativeto-zoneddatetime-negative-epochnanoseconds.js |
---
esid: sec-temporal.duration.prototype.round
description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch
info: |
sec-temporal-getisopartsfromepoch step 1:
1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 10<sup>6</sup>.
sec-temporal-builtintimezonegetplaindatetimefor step 2:
2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]).
features: [Temporal]
includes: [temporalHelpers.js]
--- |
1265 |
- |
| relativeto-zoneddatetime-slots.js |
---
esid: sec-temporal.duration.prototype.round
description: Getters are not called when converting a ZonedDateTime to a PlainDate.
includes: [compareArray.js]
features: [Temporal]
--- |
1357 |
- |
| result-out-of-range.js |
---
esid: sec-temporal.duration.prototype.round
description: >
RoundDuration throws a RangeError when the result duration is invalid.
features: [Temporal]
--- |
630 |
- |
| round-and-balance-calendar-units-with-increment-disallowed.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Disallow rounding to an increment of calendar units >1 if also balancing
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2582 |
- |
| round-cross-unit-boundary.js |
---
esid: sec-temporal.duration.prototype.round
description: Rounding can cross unit boundaries up to the implicit largestUnit
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1955 |
- |
| round-negative-result.js |
---
esid: sec-temporal.duration.prototype.round
description: A negative duration result is balanced correctly by the modulo operation in NanosecondsToDays
info: |
sec-temporal-nanosecondstodays step 6:
6. If Type(_relativeTo_) is not Object or _relativeTo_ does not have an [[InitializedTemporalZonedDateTime]] internal slot, then
a. Return the new Record { ..., [[Nanoseconds]]\: abs(_nanoseconds_) modulo _dayLengthNs_ × _sign_, ... }.
sec-temporal-roundduration step 6:
6. If _unit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then
...
d. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _intermediate_).
sec-temporal.duration.prototype.round step 21:
21. Let _roundResult_ be ? RoundDuration(_unbalanceResult_.[[Years]], _unbalanceResult_.[[Months]], _unbalanceResult_.[[Weeks]], _unbalanceResult_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_[[Seconds]], _duration_[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _relativeTo_).
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1594 |
- |
| rounding-increment-relativeto.js |
---
esid: sec-temporal.duration.prototype.round
description: Test a specific buggy case from temporal_rs
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2066 |
- |
| rounding-increments.js |
---
esid: sec-temporal.duration.prototype.round
description: Test various rounding increments.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
3510 |
- |
| rounding-is-noop.js |
---
esid: sec-temporal.duration.prototype.round
description: >
Circumstances where rounding is a no-op, return a new but equal duration
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2142 |
- |
| rounding-window.js |
---
esid: sec-temporal.duration.prototype.round
description: See https://github.com/tc39/proposal-temporal/issues/3168
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1299 |
- |
| roundingincrement-days-large.js |
---
esid: sec-temporal.duration.prototype.round
description: Calculation with a large, but not too large, roundingIncrement
features: [Temporal]
includes: [temporalHelpers.js]
--- |
1379 |
- |
| roundingincrement-nan.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when roundingIncrement option is NaN
info: |
sec-getoption step 8.b:
b. If _value_ is *NaN*, throw a *RangeError* exception.
sec-temporal-totemporalroundingincrement step 5:
5. Let _increment_ be ? GetOption(_normalizedOptions_, *"roundingIncrement"*, « Number », *undefined*, 1).
sec-temporal.duration.prototype.round step 18:
18. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, _maximum_, *false*).
features: [Temporal]
--- |
990 |
- |
| roundingincrement-non-integer.js |
---
esid: sec-temporal.duration.prototype.round
description: Rounding for roundingIncrement option
info: |
sec-temporal-totemporalroundingincrement:
3. Let _integerIncrement_ be truncate(ℝ(_increment_)).
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1078 |
- |
| roundingincrement-out-of-range.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when roundingIncrement option out of range
info: |
sec-temporal-totemporalroundingincrement:
4. If _integerIncrement_ < 1 or _integerIncrement_ > 10<sup>9</sup>, throw a *RangeError* exception.
features: [Temporal]
--- |
1152 |
- |
| roundingincrement-undefined.js |
---
esid: sec-temporal.duration.prototype.round
description: Fallback value for roundingIncrement option
info: |
sec-getoption step 3:
3. If _value_ is *undefined*, return _fallback_.
sec-temporal-totemporalroundingincrement step 5:
5. Let _increment_ be ? GetOption(_normalizedOptions_, *"roundingIncrement"*, « Number », *undefined*, 1).
sec-temporal.duration.prototype.round step 18:
18. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, _maximum_, *false*).
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1272 |
- |
| roundingincrement-wrong-type.js |
---
esid: sec-temporal.plaintime.prototype.round
description: Type conversions for roundingIncrement option
info: |
sec-getoption step 8.a:
a. Set _value_ to ? ToNumber(value).
sec-temporal-totemporalroundingincrement step 5:
5. Let _increment_ be ? GetOption(_normalizedOptions_, *"roundingIncrement"*, « Number », *undefined*, 1).
sec-temporal.plaintime.prototype.round step 11:
11. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, _maximum_, *false*).
includes: [temporalHelpers.js, compareArray.js]
features: [Temporal]
--- |
1260 |
- |
| roundingmode-ceil.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "ceil".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2295 |
- |
| roundingmode-expand.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "expand".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2299 |
- |
| roundingmode-floor.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "floor".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2297 |
- |
| roundingmode-halfCeil.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "halfCeil".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2303 |
- |
| roundingmode-halfEven.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "halfEven".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2303 |
- |
| roundingmode-halfExpand.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "halfExpand".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2307 |
- |
| roundingmode-halfFloor.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "halfFloor".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2305 |
- |
| roundingmode-halfTrunc.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "halfTrunc".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2305 |
- |
| roundingmode-invalid-string.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when roundingMode option not one of the allowed string values
features: [Temporal]
--- |
707 |
- |
| roundingmode-trunc.js |
---
esid: sec-temporal.duration.prototype.round
description: Tests calculations with roundingMode "trunc".
includes: [temporalHelpers.js]
features: [Temporal]
--- |
2297 |
- |
| roundingmode-undefined.js |
---
esid: sec-temporal.duration.prototype.round
description: Fallback value for roundingMode option
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1654 |
- |
| roundingmode-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: Type conversions for roundingMode option
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
771 |
- |
| roundto-invalid-string.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when smallestUnit option not one of the allowed string values
features: [Temporal]
--- |
865 |
- |
| shell.js |
---
description: |
Test if a given function is a constructor function.
defines: [isConstructor]
features: [Reflect.construct]
--- |
596 |
- |
| singular-units.js |
---
esid: sec-temporal.duration.prototype.round
description: Test that round() accepts singular units.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
3165 |
- |
| smallestunit-invalid-string.js |
---
esid: sec-temporal.duration.prototype.round
description: RangeError thrown when smallestUnit option not one of the allowed string values
features: [Temporal]
--- |
869 |
- |
| smallestunit-plurals-accepted-string.js |
---
esid: sec-temporal.duration.prototype.round
description: Plural units are accepted as well for the shorthand for the smallestUnit option
includes: [temporalHelpers.js]
features: [Temporal, arrow-function]
--- |
761 |
- |
| smallestunit-plurals-accepted.js |
---
esid: sec-temporal.duration.prototype.round
description: Plural units are accepted as well for the smallestUnit option
includes: [temporalHelpers.js]
features: [Temporal]
--- |
829 |
- |
| smallestunit-string-shorthand-string.js |
---
esid: sec-temporal.duration.prototype.round
description: String as first argument is equivalent to options bag with smallestUnit option
includes: [temporalHelpers.js]
features: [Temporal, arrow-function]
--- |
934 |
- |
| smallestunit-undefined.js |
---
esid: sec-temporal.duration.prototype.round
description: Fallback value for smallestUnit option
includes: [temporalHelpers.js]
features: [Temporal]
--- |
860 |
- |
| smallestunit-wrong-type.js |
---
esid: sec-temporal.duration.prototype.round
description: Type conversions for smallestUnit option
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
--- |
743 |
- |
| smallestunit.js |
---
esid: sec-temporal.duration.prototype.round
description: smallestUnit should be taken into account
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1208 |
- |
| string-shorthand-no-object-prototype-pollution.js |
---
esid: sec-temporal.duration.prototype.round
description: String argument creates options object with null prototype, so Object.prototype pollution doesn't affect it
features: [Temporal]
--- |
907 |
- |
| subclassing-ignored.js |
---
esid: sec-temporal.duration.prototype.round
description: Objects of a subclass are never created as return values.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
661 |
- |
| succeeds-with-largest-unit-auto.js |
---
esid: sec-temporal.duration.prototype.round
description: round() succeeds with largestUnit 'auto'.
includes: [temporalHelpers.js]
features: [Temporal]
--- |
618 |
- |
| throws-if-neither-largestUnit-nor-smallestUnit-is-given.js |
---
esid: sec-temporal.duration.prototype.round
description: round() throws if neither largestUnit nor smallestUnit is given
features: [Temporal]
--- |
715 |
- |
| throws-on-wrong-offset-for-zoned-date-time-relative-to.js |
---
esid: sec-temporal.duration.prototype.round
description: round() throws on wrong offset for ZonedDateTime relativeTo string
features: [Temporal]
--- |
595 |
- |
| total-duration-nanoseconds-too-large-with-zoned-datetime.js |
---
esid: sec-temporal.duration.prototype.round
description: >
NanosecondsToDays throws a RangeError when the number of nanoseconds is too large.
features: [Temporal]
--- |
1275 |
- |
| valid-increments.js |
---
esid: sec-temporal.duration.prototype.round
description: Test valid rounding increments (correct divisibility).
features: [Temporal]
--- |
1732 |
- |
| year-zero.js |
---
esid: sec-temporal.duration.prototype.round
description: Negative zero, as an extended year, is rejected
features: [Temporal, arrow-function]
--- |
638 |
- |
| zero-duration.js |
---
esid: sec-temporal.duration.prototype.round
description: Rounding zero duration returns 0
includes: [temporalHelpers.js]
features: [Temporal]
--- |
1461 |
- |