rianjs / ical.net

ical.NET - an open source iCal library for .NET
MIT License
782 stars 230 forks source link

Bug: ByDay does not skip passed day properly #505

Open vzam opened 3 years ago

vzam commented 3 years ago

Issue description

Example: Rule matches every 2 weeks, Friday and Sunday. Start of week is Monday. When the reference date starts at Saturday, Friday should be skipped altogether for the first week. The second week would not contain any occurrences and the third week would contain occurrences for both days. What we get in this example is, that iCal.Net wraps Friday into the next week and as a consequence, the first three weeks using this rule all have at least one occurrence which in turn violates the rule.

Steps to reproduce the issue

  1. Use this RRULE with the RecurrencePatternEvaluator: FREQ=WEEKLY;COUNT=5;INTERVAL=2;BYDAY=FR,SU;WKST=MO.
  2. Start at a Saturday, e.g. 2021-01-02

What's the expected result?

These should be the first occurences:

"2021-01-03" // Week 1
"2021-01-15" // Week 3
"2021-01-17" // Week 3
"2021-01-29" // Week 5
"2021-01-31" // Week 5

What's the actual result?

These are the first occurences:

"2021-01-03" // Week 1
"2021-01-08" // Week 2 <<<< This has been carried over from the previous week
"2021-01-15" // Week 3
"2021-01-17" // Week 3
"2021-01-29" // Week 5