Implement BYDAY with offset and limiting behavior#887
Conversation
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #887 +/- ##
=======================================
+ Coverage 68.3% 68.5% +0.2%
=======================================
Files 115 115
Lines 4376 4394 +18
Branches 1010 1011 +1
=======================================
+ Hits 2988 3008 +20
Misses 1028 1028
+ Partials 360 358 -2
🚀 New features to boost your workflow:
|
303983c to
ce242db
Compare
|
FYI, I made several tests related to this for a new recurrence evaluator. I ran those tests against this fix and they all pass. |
e218233 to
757f9fc
Compare
|
@maknapp Thanks for the review and the helpful hint
So it looks like we're on the right way. As @minichma opened the issue, I'd like have his feedback as well, if he finds the time. He also contributes to libical. |
f276890 to
d2dc0dd
Compare
|
@minichma Unit test for this PR are now part of |
The following `RRULE` cases were not implemented (see the diff for newly added unit tests for details): 1. YEARLY + BYMONTH + numeric BYDAY offsets - Pattern: `FREQ=YEARLY;BYMONTH=6,9;BYDAY=2MO` - Semantics: treat numeric BYDAY as “nth weekday inside each BYMONTH” (produce the 2nd Monday of each specified month). 2. YEARLY + numeric BYDAY without BYMONTH - Pattern: `FREQ=YEARLY;BYDAY=20MO` - Semantics: interpret numeric BYDAY as “nth weekday of the YEAR” (the 20th Monday of the year). 3. YEARLY + BYMONTH + negative numeric BYDAY - Pattern: `FREQ=YEARLY;BYMONTH=6,9;BYDAY=-1SU` - Semantics: negative offsets select from the end of the month (e.g. `-1SU` → last Sunday in each BYMONTH). 4. Implemented the per-month offset expansion and preserved BYWEEKNO / BYMONTH compatibility and negative-offset These behaviors are closely related and required special handling in `RecurrencePatternEvaluator.GetAbsWeekDays` and `GetAbsWeekDaysYearlyPerMonthOffsets`. Fixes #782
Updated recurrence yearly offset tests to use hardcoded CalDateTime values instead of CalCalc helper methods. Removed CalCalc.cs as its methods are no longer referenced.
Move tests are for RFC errata 1913 (https://www.rfc-editor.org/errata_search.php?rfc=1913&eid=1913) and contain the disclaimer "Other iCalendar libraries may interpret this differently"
c48b1c2 to
7d556e8
Compare
minichma
left a comment
There was a problem hiding this comment.
I started looking at the test cases and from my point of view they look good. Commented some minor thoughts, just nits. Didn't look at the actual code so far. Will try to find time at the weekend.
|
|
||
| # Yearly BYMONTH numeric BYDAY (2MO) - 2nd Monday in each BYMONTH | ||
| RRULE:FREQ=YEARLY;BYMONTH=6,9;BYDAY=2MO;COUNT=4 | ||
| DTSTART:20260601T090000 |
There was a problem hiding this comment.
DTSTART is not in line with the RRULE, which makes the case undefined according to the RFC (similar in other test cases). Unless this test should explicitly cover the undefined case, it would be good to have DTSTART aligned with RRULE, otherwise readers would have to think about whether the deviation is intentional.
The time part could be omitted, which would make the test somewhat more concise.
minichma
left a comment
There was a problem hiding this comment.
Very nice! Sorry for the delay!
|



The following
RRULEcases were not implemented (see the diff for newly added unit tests for details):YEARLY + BYMONTH + numeric BYDAY offsets
FREQ=YEARLY;BYMONTH=6,9;BYDAY=2MOYEARLY + numeric BYDAY without BYMONTH
FREQ=YEARLY;BYDAY=20MOYEARLY + BYMONTH + negative numeric BYDAY
FREQ=YEARLY;BYMONTH=6,9;BYDAY=-1SU-1SU→ last Sunday in each BYMONTH).Implemented the per-month offset expansion and preserved BYWEEKNO / BYMONTH compatibility and negative-offset
These behaviors are closely related and required special handling in
RecurrencePatternEvaluator.GetAbsWeekDaysandGetAbsWeekDaysYearlyPerMonthOffsets.[Edit]
Relevant unit tests in
RecurrenceTestCases.txtcontain a disclaimer regarding RFC5545 interpretation in ical.netFixes #782
Closes #888