Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different duration balancing PlainDate::until vs Duration::round #2563

Closed
arshaw opened this issue Apr 22, 2023 · 3 comments · Fixed by #2571
Closed

Different duration balancing PlainDate::until vs Duration::round #2563

arshaw opened this issue Apr 22, 2023 · 3 comments · Fixed by #2571
Assignees
Labels
bug normative Would be a normative change to the proposal spec-text Specification text involved

Comments

@arshaw
Copy link
Contributor

arshaw commented Apr 22, 2023

Rounding-up and balancing-up works differently depending whether PlainDate::until is used or Calendar::round is used with relativeTo. This seems very similar to this recently-closed issue.

const past = Temporal.PlainDate.from('2022-01-01')
const future = Temporal.PlainDate.from('2023-12-25')

const durationViaUntil = past.until(future, {
  largestUnit: 'year',
  smallestUnit: 'month',
  roundingMode: 'ceil'
})
console.log(durationViaUntil.toString()) // P1Y12M (undesirable result IMO)

const durationViaRound = past.until(future).round({
  relativeTo: past,
  largestUnit: 'year',
  smallestUnit: 'month',
  roundingMode: 'ceil'
})
console.log(durationViaRound.toString()) // P2Y (expected result)
@ptomato
Copy link
Collaborator

ptomato commented Apr 27, 2023

Thanks for reporting this. This looks like it's a bug, indeed. We need to verify whether it's actually a bug in the spec (in which case it'd need to be presented for consensus in TC39) or just a mistake in the polyfill.

@ptomato ptomato added the bug label Apr 27, 2023
@ptomato
Copy link
Collaborator

ptomato commented May 2, 2023

This is unfortunately a bug in the spec text and PlainDate.until is not the only place it occurs. It's caused by RoundDuration not being followed by BalanceDuration and/or BalanceDurationRelative as it is in Temporal.Duration.prototype.round(). Here are all the situations where it occurs, as far as I can tell:

const roundingMode = 'ceil';

// PlainDate.until and since (original example)
const pdPast = Temporal.PlainDate.from('2022-01-01');
const pdFuture = Temporal.PlainDate.from('2023-12-25');
pdPast.until(pdFuture, {largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P1Y12M
pdPast.until(pdFuture).round({relativeTo: pdPast, largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P2Y

// PlainDateTime.until and since
// NB. The problem exists for date units, but time units work correctly
const pdtPast = Temporal.PlainDateTime.from('2022-01-01T00');
const pdtFuture = Temporal.PlainDateTime.from('2023-12-25T00');
pdtPast.until(pdtFuture, {largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P1Y12M
pdtPast.until(pdtFuture).round({relativeTo: pdPast, largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P2Y

// ZonedDateTime.until and since
const zdtPast = Temporal.ZonedDateTime.from('2022-01-01T00[UTC]');
const zdtFuture = Temporal.ZonedDateTime.from('2023-12-25T00[UTC]');
zdtPast.until(zdtFuture, {largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P1Y12M
zdtPast.until(zdtFuture).round({relativeTo: zdtPast, largestUnit: 'year', smallestUnit: 'month', roundingMode})
  // => P2Y

// PlainYearMonth.until and since
const pymPast = Temporal.PlainYearMonth.from('2022-01');
const pymFuture = Temporal.PlainYearMonth.from('2023-12');
pymPast.until(pymFuture, {largestUnit: 'year', smallestUnit: 'month', roundingIncrement: 3, roundingMode})
  // => P1Y12M
pymPast.until(pymFuture).round({relativeTo: pdPast, largestUnit: 'year', smallestUnit: 'month', roundingIncrement: 3, roundingMode})
  // => P2Y

// Duration.toString
const duration = Temporal.Duration.from('PT1H59M59.9S');
duration.toString({smallestUnit: 'second', roundingMode: 'ceil'})
  // => 'PT1H59M60S'
duration.round({smallestUnit: 'second', roundingMode}).toString()
  // => 'PT2H'

With time units, it's generally already implemented correctly (except for Duration.toString):

Temporal.PlainTime.from('00:00').until('01:59:59', {largestUnit: 'hour', smallestUnit: 'minute', roundingMode})
  // => PT2H
Temporal.Instant.fromEpochSeconds(0).until(Temporal.Instant.fromEpochSeconds(7199), {largestUnit: 'hour', smallestUnit: 'minute', roundingMode})
  // => PT2H

@ptomato ptomato added spec-text Specification text involved normative Would be a normative change to the proposal labels May 2, 2023
@ptomato ptomato self-assigned this May 2, 2023
ptomato added a commit that referenced this issue May 2, 2023
I'm going to make some changes to TemporalDurationToString in order to fix
bug #2563. It will be helpful to have it do everything in the same order
as the spec text, to verify that the changes work.
ptomato added a commit to ptomato/test262 that referenced this issue May 3, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue May 3, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue May 3, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue May 11, 2023
I'm going to make some changes to TemporalDurationToString in order to fix
bug #2563. It will be helpful to have it do everything in the same order
as the spec text, to verify that the changes work.
ptomato added a commit that referenced this issue May 11, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue May 13, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue May 13, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue May 19, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue May 31, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Jun 12, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDurationRelative after RoundDuration
in the until()/since() methods that deal with date units (time units
already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceDuration. I was not sure whether it was
intentional that we didn't call this, but as far as I can determine from
in `toString()` was "controls rounding, works same as `round()`", but the
status quo was that it worked differently from `round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Jun 12, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Jun 12, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit to ptomato/test262 that referenced this issue Jun 20, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Jun 20, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Jun 20, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
@justingrant
Copy link
Collaborator

Meeting 2023-08-17: We'll fix this and the fix has already been approved. Will be fixed in #2571 which is stacked on other PRs at the moment.

ptomato added a commit that referenced this issue Sep 19, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Sep 20, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Sep 20, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Sep 21, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Sep 22, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Sep 26, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Sep 27, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Sep 28, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Sep 28, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Sep 28, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Sep 28, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Oct 4, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Oct 4, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 4, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 18, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 18, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Oct 18, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Oct 19, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 19, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 26, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Oct 26, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Oct 26, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Nov 6, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Nov 6, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Nov 6, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit that referenced this issue Nov 6, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit to ptomato/test262 that referenced this issue Nov 14, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit to ptomato/test262 that referenced this issue Nov 14, 2023
In order to fix tc39/proposal-temporal#2563, we added invocations of
BalanceDurationRelative after some invocations of RoundDuration. These
cause observable calendar calls, which must be accounted for in some
existing tests.
ptomato added a commit to tc39/test262 that referenced this issue Nov 14, 2023
See tc39/proposal-temporal#2563

The old behaviour was encoded in one test in staging, but the behaviour of
largestUnit in duration rounding has changed since that test was written.
Therefore I'm assuming that toString() should've been updated when that
happened.
ptomato added a commit that referenced this issue Nov 14, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
ptomato added a commit that referenced this issue Nov 14, 2023
…ng()

In cases where a number rounded up to the next unit, we would previously
return a result that didn't respect the `largestUnit` option in the same
way that Duration.prototype.round() would.

To fix this, we need to call BalanceDateDurationRelative after
RoundDuration in the until()/since() methods that deal with date units
(time units already behaved correctly).

In Duration.prototype.toString() where time units did not already behave
correctly, we need to call BalanceTimeDuration. I was not sure whether it
was intentional that we didn't call this, but as far as I can determine
from the previous discussions, `toString()` was "controls rounding, works
same as `round()`", but the status quo was that it worked differently from
`round()`.)

Closes: #2563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug normative Would be a normative change to the proposal spec-text Specification text involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants