Skip to content

Unify day-of-week calculation #6368

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
Mar 27, 2025
Merged

Conversation

robertbastian
Copy link
Member

Weekdays are not calender-specific, and the current code is overly complex.

sffc
sffc previously approved these changes Mar 27, 2025
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I approve but would like @Manishearth to also approve

Comment on lines -117 to -119
fn day_of_week(&self, date: &Self::DateInner) -> types::Weekday {
// For the purposes of the calculation here, Monday is 0, Sunday is 6
// ISO has Monday=1, Sunday=7, which we transform in the last step
Copy link
Member

Choose a reason for hiding this comment

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

This code was originally written by @Manishearth in 67bd340. We later found a bug involving rem_euclid that I fixed in 6899eda.

I don't know why we ever had this code instead of doing the simpler to_fixed().rem_euclid(7) type of approach that you propose in this PR.

@robertbastian robertbastian merged commit f67645a into unicode-org:main Mar 27, 2025
28 checks passed
@robertbastian robertbastian deleted the week branch March 27, 2025 21:07
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.

3 participants