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

NudgeToDayOrTime: "remainder" not converted to Normalized Time Duration Record #2889

Open
anba opened this issue Jun 7, 2024 · 0 comments
Open
Assignees

Comments

@anba
Copy link
Contributor

anba commented Jun 7, 2024

Step 16.b:

Set remainder to remainder(roundedFractionalDays, 1) × nsPerDay.

Step 17:

Let resultDuration be ? CreateNormalizedDurationRecord(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], days, remainder).

But CreateNormalizedDurationRecord requires remainder to be a Normalized Time Duration Record.


Do we actually need to use remainder in step 16.b? Implementation-wise it seems easier to subtract from roundedNorm to compute the remainder:

Set remainder to ! SubtractNormalizedTimeDuration(roundedNorm, NormalizeTimeDuration(roundedWholeDays * HoursPerDay, 0, 0, 0, 0, 0)).

This will also allow to simplify steps 8-9:

  1. Let roundedFractionalDays be DivideNormalizedTimeDuration(roundedNorm, nsPerDay).
  2. Let roundedWholeDays be truncate(roundedFractionalDays).

to just:

  1. Let roundedWholeDays be truncate(DivideNormalizedTimeDuration(roundedNorm, nsPerDay)).

where truncate division matches integer division, which will likely be used by implementations for these steps.

@ptomato ptomato self-assigned this Jul 24, 2024
ptomato added a commit that referenced this issue Jul 24, 2024
roundedFractionalDays/roundedDaysRemainder isn't needed, and would be more
of a hassle for implementations to calculate anyway.

Closes: #2889
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