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

a 夏天 提交于 2019-12-07 02:24:22

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/26050521/scheduling-a-monthly-event-every-nth-weekday-using-rfc-5545-recurrence-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!