Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iCalendar Spec RRULE Multiple Times?

Tags:

I'm developing some software which interfaces with the Google Calendar API, and one feature my users will be able to take advantage of is setting multiple event times for a single "class" (i.e. the class is 2-5 on some days and 3-6 on others).

Is it possible for a recurrence rule to specify a different time for different days, allowing me to create one repeating event instead of multiple?

Thank you!

like image 382
ccrama Avatar asked Jul 10 '16 21:07

ccrama


People also ask

What is recurrence rule?

A recurrence rule, commonly referred to as an RRULE, defines the repeat pattern or rule for to-dos, journal entries and events. If specified, RRULE can be used to compute the recurrence set (the complete set of recurrence instances in a calendar component).

What is WKST in Rrule?

For example, when using YEARLY, an interval of 2 means once every two years, but with HOURLY, it means once every two hours. The default interval is 1. wkst – The week start day. Must be one of the MO, TU, WE constants, or an integer, specifying the first day of the week.


1 Answers

Is it possible for a recurrence rule to specify a different time for different days, allowing me to create one repeating event instead of multiple?

No, not really, but you can achieve this result with other methods.

  • If there is a pattern, you can combine multiple RRULE. For example one repeat every other days starting Monday at 2, the second one repeat every other days starting Tuesday at 3. So the combined result will be Mon at 2, Tue at 3, Wed at 2, and so on. Though note that according to the RFC you SHOULD NOT define more than one RRULE (see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3)

it SHOULD NOT be specified more than once. The recurrence set generated with multiple "RRULE" properties is undefined.

So the behavior depends on the actual implementation and I do not know about Google Calendar API. Most libraries I know of do support multiple RRULE though, so you should give it a try.

  • Again, if there is a pattern, you can also use BYSETPOS. It's a bit complicated to wrap your head around this one, but basically you need to generate a set of occurrences (for example, over a week) and then cherry pick the ones that are valid. Try something like this (multi-lines for clarity):
DTSTART=20160711T140000
FREQ=WEEKLY
BYDAY=MO,TU,WE,TH,FR
BYHOUR=14,15
BYSETPOS=1,4,5,8,9

This will alternate Monday at 2, Tuesday at 3, Wednesday at 2, and so on. Again, you need a clear repetitive pattern for this one to work.

  • If there is no pattern and you just want to have some days with a different time, combine your RRULE with RDATE and EXDATE to add or remove special occurrences.
like image 100
rlanvin Avatar answered Sep 28 '22 04:09

rlanvin