Skip to content

Fix bug with rounding with zoned RelativeTo and increment#696

Merged
Manishearth merged 1 commit intoboa-dev:mainfrom
Manishearth:round-increment
Mar 20, 2026
Merged

Fix bug with rounding with zoned RelativeTo and increment#696
Manishearth merged 1 commit intoboa-dev:mainfrom
Manishearth:round-increment

Conversation

@Manishearth
Copy link
Contributor

@Manishearth Manishearth commented Mar 17, 2026

I only somewhat understand the math here, but opening a PR so @nekevss can look at it.

This is really two fixes:

  • nudge_calendar_unit had swapped the math
  • UnsignedRoundingMode::apply() was comparing dividend and divisor without looking at r1 and r2, which meant it was ignoring the increment.

Somehow they were canceling out. We should carefully run test262 on this before landing.

I'm not sure if the math here is safe to perform. It's frustrating that the spec handwaves this by speccing something unimplementable (NudgeToCalendarUnit step 15) and then having a implementation note: this is the second bug today (#695) where I am dealing with bugs arising from spec text that is not directly implementable.

@Manishearth Manishearth requested a review from nekevss March 17, 2026 01:55
@Manishearth Manishearth force-pushed the round-increment branch 6 times, most recently from 7e8154f to 0e9d5c6 Compare March 17, 2026 16:22
@Manishearth
Copy link
Contributor Author

No new failures. I'm going to patch this in upstream.

@Manishearth Manishearth requested a review from jedel1043 March 19, 2026 17:56
@Manishearth Manishearth force-pushed the round-increment branch 2 times, most recently from f3bdb5c to 7d6a73d Compare March 19, 2026 22:29
Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, no new failures in Boa also.

I did have one question, but approving the PR as is.

..Default::default()
};

// let result = duration.round(options.clone(), None).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from debugging

@Manishearth Manishearth merged commit dbd731d into boa-dev:main Mar 20, 2026
8 checks passed
@Manishearth Manishearth deleted the round-increment branch March 20, 2026 16:36
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

Successfully merging this pull request may close these issues.

2 participants