Skip to content

Add validation logic to from_diff_settings #144

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

Merged
merged 4 commits into from
Dec 26, 2024
Merged

Conversation

nekevss
Copy link
Member

@nekevss nekevss commented Dec 25, 2024

This PR adds missing steps from GetDifferenceSettings to the options resolution logic of from_diff_settings

src/options.rs Outdated
// 11. If LargerOfTwoTemporalUnits(largestUnit, smallestUnit) is not largestUnit, throw a RangeError exception.
// 12. Let maximum be MaximumTemporalDurationRoundingIncrement(smallestUnit).
// 13. If maximum is not unset, perform ? ValidateTemporalRoundingIncrement(roundingIncrement, maximum, false).
if largest_unit.max(smallest_unit) != largest_unit {
Copy link
Member

Choose a reason for hiding this comment

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

Does TemporalUnit implement Ord? Because even if the spec says otherwise, I think it would be better to do a simpler if largest_unit < smallest_unit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmmmm, yeah that's probably true. I believe it should implement Ord

@nekevss nekevss requested a review from jedel1043 December 26, 2024 07:36
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jedel1043 jedel1043 merged commit 8b796ed into main Dec 26, 2024
5 checks passed
@nekevss nekevss deleted the diff-settings-validation branch December 27, 2024 22:07
@jedel1043 jedel1043 added the C-internal Internal library improvements label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internal Internal library improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants