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!
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).
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.
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.
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.
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.
RRULE
with RDATE
and EXDATE
to add or remove special occurrences.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With