Search code examples
google-calendar-apiicalendarrrule

Calendar recurrent rule - Consecutive days: Every First and third Friday and Saturday


In Google Calendar, using rrule, I want to make recurrent events for two consecutive days:

  • Friday and Saturday
  • Twice a month with 2 weeks apart

What I would expect to match my requirement is any of the 2 options below:

Possible option 1st match 2nd match
1 fri 30 - sat 1 fri 14 - sat 15
2 fri 7 - sat 8 fri 21 - sat 22

The below config shows what I have tried and the screenshot shows the outcome which is certainly not what I want.

The tricky part I believe is when the two days belong to 2 different moths. Luckily I noticed this since it was the case this May.

Any idea how to solve this?

BEGIN:VCALENDAR
VERSION:2.0

BEGIN:VEVENT
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYSETPOS=1
SUMMARY:EventDay1
DTSTART;VALUE=DATE:20210501
SEQUENCE:0
DESCRIPTION:EventDay1
END:VEVENT
BEGIN:VEVENT
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYSETPOS=3
SUMMARY:EventDay1
DTSTART;VALUE=DATE:20210501
SEQUENCE:0
DESCRIPTION:EventDay1
END:VEVENT

BEGIN:VEVENT
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=SA;BYSETPOS=1
SUMMARY:EventDay2
DTSTART;VALUE=DATE:20210501
SEQUENCE:0
DESCRIPTION:EventDay2
END:VEVENT
BEGIN:VEVENT
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=SA;BYSETPOS=3
SUMMARY:EventDay2
DTSTART;VALUE=DATE:20210501
SEQUENCE:0
DESCRIPTION:EventDay2
END:VEVENT

END:VCALENDAR

enter image description here


Solution

  • You could use BYMONTHDAY instead of BYSETPOS to specify the first and third weeks of the month:

    • 1st Friday: BYMONTHDAY=1,2,3,4,5,6,7
    • 1st Saturday: BYMONTHDAY=2,3,4,5,6,7,8
    • 3rd Friday: BYMONTHDAY=15,16,17,18,19,20,21
    • 3rd Saturday: BYMONTHDAY=16,17,18,19,20,21,22

    Arguably less elegant than BYSETPOS, but it solves the issue:

    BEGIN:VCALENDAR
    VERSION:2.0
    
    BEGIN:VEVENT
    RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=1,2,3,4,5,6,7
    SUMMARY:EventDay1
    DTSTART;VALUE=DATE:20210430
    EXDATE;VALUE=DATE:20210430
    SEQUENCE:0
    DESCRIPTION:EventDay1
    END:VEVENT
    BEGIN:VEVENT
    RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=15,16,17,18,19,20,21
    SUMMARY:EventDay1
    DTSTART;VALUE=DATE:20210430
    EXDATE;VALUE=DATE:20210430
    SEQUENCE:0
    DESCRIPTION:EventDay1
    END:VEVENT
    
    BEGIN:VEVENT
    RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=SA;BYMONTHDAY=2,3,4,5,6,7,8
    SUMMARY:EventDay2
    DTSTART;VALUE=DATE:20210430
    EXDATE;VALUE=DATE:20210430
    SEQUENCE:0
    DESCRIPTION:EventDay2
    END:VEVENT
    BEGIN:VEVENT
    RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=SA;BYMONTHDAY=16,17,18,19,20,21,22
    SUMMARY:EventDay2
    DTSTART;VALUE=DATE:20210430
    EXDATE;VALUE=DATE:20210430
    SEQUENCE:0
    DESCRIPTION:EventDay2
    END:VEVENT
    
    END:VCALENDAR