-
Notifications
You must be signed in to change notification settings - Fork 191
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
Conversation
@swift-ci please test |
// in case the start date falls on a leap month | ||
componentsForEnumerating.month = 1 | ||
componentsForEnumerating.isLeapMonth = nil | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Sources/FoundationEssentials/Calendar/Calendar_Recurrence.swift
Outdated
Show resolved
Hide resolved
…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.
3a4da11
to
8ab1d1d
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
…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.
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.