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

Temporal.Duration.prototype.round: Does roundingGranularityIsNoop=false really imply plainDateTimeOrRelativeToWillBeUsed=true? #2698

Closed
anba opened this issue Oct 10, 2023 · 2 comments
Assignees

Comments

@anba
Copy link
Contributor

anba commented Oct 10, 2023

Temporal.Duration.prototype.round, step 32 sets plainDateTimeOrRelativeToWillBeUsed to true when roundingGranularityIsNoop is false.

It's not clear to me why roundingGranularityIsNoop tested here and if roundingGranularityIsNoop = false is indeed a correct condition, then plainDateTimeOrRelativeToWillBeUsed doesn't need to test smallestUnit, because when smallestUnit is larger or equal to "day", then roundingGranularityIsNoop is guaranteed to be false.

@anba
Copy link
Contributor Author

anba commented Oct 11, 2023

It's not clear to me why roundingGranularityIsNoop tested here [...]

Ah, I guess it's for AdjustRoundedDurationDays, which has a fast-path to return the input when smallestUnit = "nanosecond" and roundingIncrement = 1 (which is roundingGranularityIsNoop).

@ptomato
Copy link
Collaborator

ptomato commented Oct 11, 2023

Indeed, it's for the fast path in AdjustRoundedDurationDays. You're correct that I missed that the roundingGranularityIsNoop condition subsumes the smallestUnit condition, so I'll remove the latter.

@ptomato ptomato self-assigned this Oct 11, 2023
ptomato added a commit that referenced this issue Oct 11, 2023
In Duration.p.round(), the smallestUnit condition for precalculating the
PlainDateTime is already subsumed by the roundingGranularityIsNoop
condition, so also checking smallestUnit is redundant.

Thanks to Anba for pointing this out.

Closes: #2698
@Ms2ger Ms2ger closed this as completed in 77ba1ca Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants