ical.net icon indicating copy to clipboard operation
ical.net copied to clipboard

BYDAY and SETPOS not working properly in first week of occurrence

Open rootGst opened this issue 4 years ago • 1 comments

My intention is an event on 26th Aug. 2021 at 1:00 AM that recurs every Wednesday and Thursday at 6:00 PM and every Friday at 7:30 PM.

Calendar calendar = new Calendar();
calendar.Events.Add(new Ical.Net.CalendarComponents.CalendarEvent {
  DtStart = new CalDateTime(DateTime.Parse("2021-08-26 01:00:00")),
  DtEnd = new CalDateTime(DateTime.Parse("2021-08-26 02:00:00")),
  RecurrenceRules = {
      new RecurrencePattern("FREQ=WEEKLY;UNTIL=20210909T000000;BYDAY=WE,TH,FR;BYHOUR=18,19;BYMINUTE=0,30;BYSETPOS=1,5,12"),
    }
});

Expected occurrences:

26/08/2021 01:00:00
26/08/2021 18:00:00
27/08/2021 19:30:00
01/09/2021 18:00:00
02/09/2021 18:00:00
03/09/2021 19:30:00
08/09/2021 18:00:00

Actual occurrences:

26/08/2021 01:00:00
26/08/2021 18:00:00
27/08/2021 18:00:00 // wrong time of day for Friday of the first week
01/09/2021 18:00:00
02/09/2021 18:00:00
03/09/2021 19:30:00 // time of day for Friday of second week and beyond is correct
08/09/2021 18:00:00

It looks like this behavior applies to cases when not all weekdays provided by BYDAY occur in the remaining week of the first event.

rootGst avatar Aug 25 '21 14:08 rootGst

I think the main issue is when BYDAY has any value other than just a single week day.

For example, for me BYDAY=WE would work, but BYDAY=+2WE (2nd Wednesday) does not work, which might be the same issue with BYDAY=WE,TH.

Meligy avatar Aug 01 '22 01:08 Meligy