Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheduling a monthly event "Every Nth Weekday" using RFC 5545 recurrence rule

I'm trying to replicate some scheduling functionality in Google Calendar in C# using the RFC5545 recurrence rule.

There are two options for scheduling monthly with Google calendar, either by every Nth day month, ie: Every 10th day of the month every 1 months, this will obviously occur regardless of the week day.

My recurrence rule for this is: FREQ=MONTHLY;BYMONTHDAY=10

The other option is to repeat the event on every Nth weekday, ie: "Every second Sunday every one months, this is the one I'm having trouble writing the rule for.

What should my rule be for the second rule? I've tried FREQ=MONTHLY;BYDAY=SU, but I'm unsure how/which parameters to use to specify to only do this every 2nd Sunday of the month.

I'm using the DDay iCal C# library to generate my recurrence rule, but I'm happy to just be shown what the rule string should look like to achieve the desired behavior.

I'm using the RFC 5545 recurrence rule.

like image 921
Alex Avatar asked Sep 26 '14 01:09

Alex


1 Answers

You are nearly there. What you need is to set the index for the day, RFC5545 says:

Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer. If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE".

for which RFC5545 later gives an example

Monthly on the first Friday for 10 occurrences:

   DTSTART;TZID=America/New_York:19970905T090000
   RRULE:FREQ=MONTHLY;COUNT=10;BYDAY=1FR

so for you the rule has to be:

RRULE:FREQ=MONTHLY;BYDAY=2SU

like image 187
Auberon Vacher Avatar answered Oct 18 '22 14:10

Auberon Vacher