icalendarrrulerfc5545rfc2445

RRule for semi-weekly events


I've been trying to figure out how to compose an RRULE that has events on alternating days each week; for example:

Where Week A and Week B alternate continuously into the future.

The closest I've gotten is this:

RRULE:FREQ=WEEKLY;COUNT=30;INTERVAL=2;BYDAY=MO,FR

which is close, but gives me the monday and friday on the same week. How can I code it to select the second friday in the two-week interval? This seems much less complex than much of what can be done with RRULEs, so I'm likely missing something obvious?


Solution

  • If this is intended to go on forever, with no 'COUNT', then I think the only way you can do it is to have two events.

    Using any other of the BY's even BYSETPOS gets one into trouble at some point at the end of the year, or the end of the sequence as far as you defined it. Two events allows one to iterate the Monday and the Friday cleanly.

    The choice of DTSTART for each event is crucial to be sure that you are recurring the right Fridays after the Mondays. You have something like M fm FM fm FM fm

    From https://calendar.google.com/calendar/ical/eppua87dpfnq85bsrrt2siqlcs%40group.calendar.google.com/public/basic.ics

    BEGIN:VEVENT
    DTSTART:20211022T160000Z
    DTEND:20211022T170000Z
    RRULE:FREQ=WEEKLY;WKST=MO;INTERVAL=2;BYDAY=FR
    DTSTAMP:20211012T064353Z
    UID:STACKTESTFRIDAY
    CREATED:20171102T185254Z
    DESCRIPTION:
    LAST-MODIFIED:20211012T064141Z
    LOCATION:
    SEQUENCE:2
    STATUS:CONFIRMED
    SUMMARY:Afternoon Tea on Friday
    TRANSP:OPAQUE
    END:VEVENT
    BEGIN:VEVENT
    DTSTART:20211011T160000Z
    DTEND:20211011T180000Z
    RRULE:FREQ=WEEKLY;WKST=MO;INTERVAL=2;BYDAY=MO
    DTSTAMP:20211012T064353Z
    UID:STACKTESTMONDAY
    CREATED:20171102T185254Z
    DESCRIPTION:
    LAST-MODIFIED:20211012T064112Z
    LOCATION:
    SEQUENCE:2
    STATUS:CONFIRMED
    SUMMARY:Afternoon Tea on Monday
    TRANSP:OPAQUE
    END:VEVENT
    END:VCALENDAR