Search code examples
calendarrfc5545rrule

Can an rrule (RFC5545) be defined for an event that repeats every 2 weeks from a start day/month to an end day/month, every year?


Example:

Repeat every 2nd week on Mondays every year between January 15th and May 10th.


Solution

  • I don't think so. This is the closest you can get IMO:

    DTSTART;VALUE=DATE:20160115
    RRULE:FREQ=YEARLY;BYWEEKNO=3,5,7,9,11,13,15,17,19;BYDAY=MO
    

    Unfortunately, this will expand January 13th or 14th in certain years, which also means that all other instances in that year will be off by one week (see the first 100 instances). I think there are a few dates for which this would be correct though (because certain days in the year are always in the same calendar week).

    The only way to do that is, if start and end date of the range match the start and end of a month.

    I.e., in order to expand an event to every 2nd Monday between January 1st and May 31st each year you could do this:

    DTSTART;VALUE=DATE:20160101
    RRULE:FREQ=YEARLY;BYMONTH=1,2,3,4,5;BYDAY=MO;BYSETPOS=1,3,5,7,9,11,13,15,17,19,21,23,25,27
    

    Here are the first 100 instances of that rule. Though some RRULE implementations might not support this properly.