I am mapping the following set of recurrence rules to RFC5545 RRULEs (to create Google Calendar events):
Some of these are easier than others (consider Every4Weeks vs TwiceAMonth) and are already implemented.
Assuming this can be expressed in an RRULE and I have a start date of 2017/08/24
(if start date is relevant) what would my RRULE need to be to satisfy, for example, TwiceAMonth
?
Bonus: If anyone comes up with RRULEs for "every other week", "twice a year", etc. I would be eternally grateful.
To code an RRULE one needs to get very specific. 'Twice a week/month/year' - if you said that to a human, would they be able to work out exactly which days for 2019?
Every sequence needs a DTSTART, and it is definitely needed for a recurring sequence that depends on or is determined by that date. EG: every other week would need a day to start on, and could recur every 14 days or every 2 weeks. Twice a month: which days? is day of week relevant? are days determined by start or end of month?
You have at your disposal combinations of FREQ, INTERVAL, and all the 'BY's BYDAY, BYMONTHDAY, BYSETPOS etc. Some 'expand' the number of days and some 'limit' the number of days.
The spec itself has some examples https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html. Here are some more examples:
Twice a month on the 1st and the 15th
RRULE:FREQ=MONTHLY;BYMONTHDAY=1,15
Twice a month on the first and third thursday
DTSTART;TZID=America/New_York:20170824T000000
RRULE:FREQ=MONTHLY;BYDAY=1TH,3TH
Every other week starting from 24th Aug 2018
DTSTART;TZID=America/New_York:20170824T000000
RRULE:FREQ=WEEKLY;INTERVAL=2
Twice a year on the 2nd to last day of Feb and August
RRULE:FREQ=YEARLY;BYMONTHDAY=-2;BYMONTH=2,8
Twice a year on the last day and the 50th day
RRULE:FREQ=YEARLY;BYSETPOS=-1,50
There are many possible combinations. https://icalevents.com/2447-need-to-know-the-possible-combinations-for-repeating-dates-an-ical-cheatsheet/