Skip to content

Don't skip anchors with strict matching in Calendar.RecurrenceRule. Resolve #881 #1000

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 1 commit into from
Nov 1, 2024

Conversation

hristost
Copy link
Contributor

In recurrence rules that expand days or weekdays in a month, we first use a base recurrence to calculate "anchors" in the month, and then change the day of month or weekday to find results. Because the base recurrence used to match the day of month of the start date, we could miss anchors if matching was set to .strict. This change makes sure that if we know that the day of month is known to change, we reset it to 1 in the base recurrence.

@hristost
Copy link
Contributor Author

@swift-ci please test

@hristost hristost requested a review from parkera October 30, 2024 16:59
// in case the start date falls on a leap month
componentsForEnumerating.month = 1
componentsForEnumerating.isLeapMonth = nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we also need to handle nth-weekday and yearly combination?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch! Added more exhaustive checks and cleaned up the logic a bit to be easier to read

…esolve #881

In recurrence rules that expand days or weekdays in a month, we first use a base
recurrence to calculate "anchors" in the month, and then change the day of month
or weekday to find results. Because the base recurrence used to match the day of
month of the start date, we could miss anchors if matching was set to `.strict`.
This change makes sure that if we know that the day of month is known to change,
we reset it to 1 in the base recurrence. Likewise, we reset the month in case of
leap month.
@hristost hristost force-pushed the hs/recurrence-rule-fix-strict-start-date branch from 3a4da11 to 8ab1d1d Compare October 31, 2024 22:14
@hristost
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@hristost
Copy link
Contributor Author

hristost commented Nov 1, 2024

@swift-ci please test

@hristost hristost merged commit 71d0424 into main Nov 1, 2024
3 checks passed
@hristost hristost deleted the hs/recurrence-rule-fix-strict-start-date branch November 1, 2024 06:36
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
…esolve swiftlang#881 (swiftlang#1000)

In recurrence rules that expand days or weekdays in a month, we first use a base
recurrence to calculate "anchors" in the month, and then change the day of month
or weekday to find results. Because the base recurrence used to match the day of
month of the start date, we could miss anchors if matching was set to `.strict`.
This change makes sure that if we know that the day of month is known to change,
we reset it to 1 in the base recurrence. Likewise, we reset the month in case of
leap month.
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