diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index ad191df34..af7a4f2c9 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -3636,6 +3636,10 @@ export function GetDifferenceSettings(op, options, group, disallowed, fallbackSm ]); let largestUnit = GetTemporalUnitValuedOption(options, 'largestUnit'); + const roundingIncrement = GetRoundingIncrementOption(options); + let roundingMode = GetRoundingModeOption(options, 'trunc'); + let smallestUnit = GetTemporalUnitValuedOption(options, 'smallestUnit'); + ValidateTemporalUnitValue(largestUnit, group, ['auto']); if (!largestUnit) largestUnit = 'auto'; if (Call(ArrayPrototypeIncludes, disallowed, [largestUnit])) { @@ -3644,12 +3648,8 @@ export function GetDifferenceSettings(op, options, group, disallowed, fallbackSm ); } - const roundingIncrement = GetRoundingIncrementOption(options); - - let roundingMode = GetRoundingModeOption(options, 'trunc'); if (op === 'since') roundingMode = NegateRoundingMode(roundingMode); - let smallestUnit = GetTemporalUnitValuedOption(options, 'smallestUnit'); ValidateTemporalUnitValue(smallestUnit, group); if (!smallestUnit) smallestUnit = fallbackSmallest; if (Call(ArrayPrototypeIncludes, disallowed, [smallestUnit])) { diff --git a/polyfill/lib/instant.mjs b/polyfill/lib/instant.mjs index 0e63d276f..8198643a8 100644 --- a/polyfill/lib/instant.mjs +++ b/polyfill/lib/instant.mjs @@ -109,9 +109,9 @@ export class Instant { const digits = ES.GetTemporalFractionalSecondDigitsOption(resolvedOptions); const roundingMode = ES.GetRoundingModeOption(resolvedOptions, 'trunc'); const smallestUnit = ES.GetTemporalUnitValuedOption(resolvedOptions, 'smallestUnit'); + let timeZone = resolvedOptions.timeZone; ES.ValidateTemporalUnitValue(smallestUnit, 'time'); if (smallestUnit === 'hour') throw new RangeErrorCtor('smallestUnit must be a time unit other than "hour"'); - let timeZone = resolvedOptions.timeZone; if (timeZone !== undefined) timeZone = ES.ToTemporalTimeZoneIdentifier(timeZone); const { precision, unit, increment } = ES.ToSecondsStringPrecisionRecord(smallestUnit, digits); const ns = GetSlot(this, EPOCHNANOSECONDS); diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index ea38f5f9a..a1a236976 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -349,9 +349,9 @@ export class ZonedDateTime { const showOffset = ES.GetTemporalShowOffsetOption(resolvedOptions); const roundingMode = ES.GetRoundingModeOption(resolvedOptions, 'trunc'); const smallestUnit = ES.GetTemporalUnitValuedOption(resolvedOptions, 'smallestUnit'); + const showTimeZone = ES.GetTemporalShowTimeZoneNameOption(resolvedOptions); ES.ValidateTemporalUnitValue(smallestUnit, 'time'); if (smallestUnit === 'hour') throw new RangeErrorCtor('smallestUnit must be a time unit other than "hour"'); - const showTimeZone = ES.GetTemporalShowTimeZoneNameOption(resolvedOptions); const { precision, unit, increment } = ES.ToSecondsStringPrecisionRecord(smallestUnit, digits); return ES.TemporalZonedDateTimeToString(this, precision, showCalendar, showTimeZone, showOffset, { unit, diff --git a/spec/abstractops.html b/spec/abstractops.html index 226198acf..30735c3f7 100644 --- a/spec/abstractops.html +++ b/spec/abstractops.html @@ -1866,15 +1866,15 @@

1. NOTE: The following steps read options and perform independent validation in alphabetical order. 1. Let _largestUnit_ be ? GetTemporalUnitValuedOption(_options_, *"largestUnit"*, ~unset~). + 1. Let _roundingIncrement_ be ? GetRoundingIncrementOption(_options_). + 1. Let _roundingMode_ be ? GetRoundingModeOption(_options_, ~trunc~). + 1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_options_, *"smallestUnit"*, ~unset~). 1. Perform ? ValidateTemporalUnitValue(_largestUnit_, _unitGroup_, « ~auto~ »). 1. If _largestUnit_ is ~unset~, then 1. Set _largestUnit_ to ~auto~. 1. If _disallowedUnits_ contains _largestUnit_, throw a *RangeError* exception. - 1. Let _roundingIncrement_ be ? GetRoundingIncrementOption(_options_). - 1. Let _roundingMode_ be ? GetRoundingModeOption(_options_, ~trunc~). 1. If _operation_ is ~since~, then 1. Set _roundingMode_ to NegateRoundingMode(_roundingMode_). - 1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_options_, *"smallestUnit"*, ~unset~). 1. Perform ? ValidateTemporalUnitValue(_smallestUnit_, _unitGroup_). 1. If _smallestUnit_ is ~unset~, then 1. Set _smallestUnit_ to _fallbackSmallestUnit_. diff --git a/spec/instant.html b/spec/instant.html index 9009d6b2c..b2560dfad 100644 --- a/spec/instant.html +++ b/spec/instant.html @@ -237,9 +237,9 @@

Temporal.Instant.prototype.toString ( [ _options_ ] )

1. Let _digits_ be ? GetTemporalFractionalSecondDigitsOption(_resolvedOptions_). 1. Let _roundingMode_ be ? GetRoundingModeOption(_resolvedOptions_, ~trunc~). 1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_resolvedOptions_, *"smallestUnit"*, ~unset~). + 1. Let _timeZone_ be ? Get(_resolvedOptions_, *"timeZone"*). 1. Perform ? ValidateTemporalUnitValue(_smallestUnit_, ~time~). 1. If _smallestUnit_ is ~hour~, throw a *RangeError* exception. - 1. Let _timeZone_ be ? Get(_resolvedOptions_, *"timeZone"*). 1. If _timeZone_ is not *undefined*, then 1. Set _timeZone_ to ? ToTemporalTimeZoneIdentifier(_timeZone_). 1. Let _precision_ be ToSecondsStringPrecisionRecord(_smallestUnit_, _digits_). diff --git a/spec/zoneddatetime.html b/spec/zoneddatetime.html index 2eb8252a4..d04fab903 100644 --- a/spec/zoneddatetime.html +++ b/spec/zoneddatetime.html @@ -694,9 +694,9 @@

Temporal.ZonedDateTime.prototype.toString ( [ _options_ ] )

1. Let _showOffset_ be ? GetTemporalShowOffsetOption(_resolvedOptions_). 1. Let _roundingMode_ be ? GetRoundingModeOption(_resolvedOptions_, ~trunc~). 1. Let _smallestUnit_ be ? GetTemporalUnitValuedOption(_resolvedOptions_, *"smallestUnit"*, ~unset~). + 1. Let _showTimeZone_ be ? GetTemporalShowTimeZoneNameOption(_resolvedOptions_). 1. Perform ? ValidateTemporalUnitValue(_smallestUnit_, ~time~). 1. If _smallestUnit_ is ~hour~, throw a *RangeError* exception. - 1. Let _showTimeZone_ be ? GetTemporalShowTimeZoneNameOption(_resolvedOptions_). 1. Let _precision_ be ToSecondsStringPrecisionRecord(_smallestUnit_, _digits_). 1. Return TemporalZonedDateTimeToString(_zonedDateTime_, _precision_.[[Precision]], _showCalendar_, _showTimeZone_, _showOffset_, _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_).