Recurring exceptions in ICal - icalendar

Problem
Some reoccurring events, that don't really end at some point (like club meetings?), depend on other conditions (like holiday season). However, manually adding these exceptions would be necessary every year, as the dates might differ.
Research
I have found out about exdate (see the image of "iCalendar components and their properties" on Wikipedia (2))
Also found some possible workaround: 'just writing a script to do process such events'. This would still mean I need to process a .ics manually and import it into my calendar, which implies some limitations:
can not be determined for all time spans (e.g. holidays not fixed for more than three years)
these events would probably be separate and not reoccurring/'grouped', which makes further edits harder
Question
Is there a way to specify recurring exceptions in iCal ?
To clarify, I have a recurring event and recurring exceptions.
So for instance I have a infinitely reoccurring weekly event, that depends on the month; where it might only take place if it's not e.g. January, August, or December.
Is there a way to use another event (/calendar) to filter events by boolean logic ?
If one could use a second event (or several) to plug into exdate this would solve the first problem and add some more possibilities.
note
if this question is too specific and the original problem could be solved by other means (other calendar-formats), feel free to comment/edit/answer

RFC2445 defines an EXRULE (exception rule) property. You can use that in addition to the RRULE to define recurring exceptions.
However, RFC2445 was superseded by RFC5545, which unfortunately deprecates the EXRULE property. So, client support is questionable.
As you already proposed, automatically adding EXDATE properties is a possible solution.

BYMONTH would be another possibility, e.g. here's a rule for a club meeting that occurs the first Wednesday of every month except December (which is their Christmas party, so no business meeting)
RRULE:FREQ=MONTHLY;BYDAY=1WE;BYMONTH=1,2,3,4,5,6,7,8,9,10,11

Related

iCalendar: How to exclude a time range from a RRULE?

I would like to exclude a time range from a RRULE.
For example the RRULE:
DTSTART;VALUE=DATE-TIME:20210104T142711Z
RRULE:FREQ=HOURLY;INTERVAL=2
will create a recurrent event every two hours, but I would like to exclude a period of time during the night, for example from 22:00 to 6:00.
I have read how to exclude dates using the EXDATE property, but I have not found information in the RFC about how to exclude a period of time. Is this documented somewhere or is there a recommended way of doing this?
I suggest try
RRULE:FREQ=DAILY;BYHOUR=6,8,10,12,14,16,18,20
and test in all the applications you expect to deal with this. Some calendar applications don't do FREQ=HOURLY. EG:Last I looked, google didn't do FREQ=HOURLY. I don't know about BYHOUR. Test whether the applications will do BYHOUR?
This https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html explains the limiting or expanding of the number of recurrences.
If those are not accepted by your intended receiving applications, then another approach may be to generate multiple VEVENTS for each hour, all using FREQ=DAILY.

More control over Dialogflow's date period

I'm trying to get Dialogflow to report sales in different time periods. When I ask things like
what's the sale last month
what's the sale in march 2011
They work fine. However, if I didn't specify "last" or year, Dialogflow always think I'm asking about the upcoming period (which I guess works great for restaurant booking, etc.). For example, "what was our sale in april" would guess that I mean April of next year.
Should I write a fulfillment to deal with this or is there a way to specify only historical periods only?
Another related question is it has trouble understanding notations like 2010q1 or q2/2015 which is quite common in economics and finance. "q1/2000" would extract only q1 (correctly, but with the upcoming q1). "2000q1" wouldn't be recognized at all.
Thanks!

iCalendar Spec RRULE Multiple Times?

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!
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.
You can use multiple RRULE on Google Calendar but I do not recommend it. See the v3 API documentation -- recurrence[]. Pass an array of strings.
While Google Calendar will respect multiple RRULE, Apple Calendar currently will only use one. This means that anyone uses Apple Calendar on their laptop/phone (synced from Google Calendar) will not see all recurrences.
Also, even though Google Calendar will repeat the event correctly, the written description of repeats used in the UI only describes one RRULE.
eg. "Weekly on Thursday, until May 15, 2021", not "Weekly on Tuesday & Thursday, until May 15, 2021"

iCal rrule for two different lengths

I want to enter an event in my calendar that runs on Monday and Tuesdays from 8-3 and Saturdays from 8-12 every week. My app is supporting rrule's. Is it possible to pack that into a single rrule?
If it would be only the weekdays, then the rule would be simple and do look like:
FREQ=WEEKLY;BYDAY=MO,TU
Any hints are appreciated.
The duration of the event is not part of the rrule definition but is rather determined by the DTSTART/DTEND or DTSTART/DURATION combinations so there is no way to have one single event representing what you want (unless you create exceptions for every single instances on Saturday)
The best you can do is to use the RELATED-TO property (https://www.rfc-editor.org/rfc/rfc5545#section-3.8.4.5) to link the 2 events.

iCalendar recurrence rule for event that occurs every two years in multiple months on first weekend day

Is it possible to specify an event to occur on the 1st weekend day of multiple months every 2 years in a single RRULE? Using February and September as a test case, my first thought was:
FREQ=YEARLY;DTSTART=20140320T070000Z;INTERVAL=2;BYSETPOS=1;BYMONTH=2,9;BYDAY=SA,SU
but BYSETPOS reduces the set down to February only. I thought changing the freq to monthly would do the trick after I posted here, but applying an interval of 2 for every other year messes things up because the interval is applied to a monthly freq instead of a yearly freq.
I made this a new question because I did not include interval in my original question.
I think splitting this into multiple rrules would work, but it would greatly increase the complexity of this area of my app so I was hoping for a single rrule with a yearly freq.
Thanks!
FWIW, and since you mention it as a potential workaround, RFC5545 has removed the ability to have multiple RRULE property in a single VEVENT/VTODO (https://www.rfc-editor.org/rfc/rfc5545#section-3.6.1). It was there in RFC2445.
Then, unless someone finds a very elegant and simple solution, you may be left with something that is so convoluted that most clients will barf on it (don't know how interoperability is important to you).
This leaves you with 2 choices I think:
either use 2 different events (maybe linked with a RELATED-TO property)
or, if you can bound the event to a certain number of instances, represent it as a set of RDATE (or RRULE + RDATE, or RRULE + EXDATE, etc...).
Adding BYSETPOS like this may work as you intend:
FREQ=YEARLY;INTERVAL=2;BYMONTH=2,9;BYDAY=+1SA,+1SU;BYSETPOS=1,3
what you could try is to take advantage of the fact that bysetpos allows you to select within the year the selected instances of your rule, then you could limit the number of instances to the first week of the month (by setting the days of the month to the first 6 ones) to avoid the cases where month have more or less weeks, which then allows you to select the first and third instance in your year.
Which then gives:
DTSTART:20140320T060000Z
FREQ=YEARLY;INTERVAL=2;WKST=MO;BYSETPOS=1,3;BYMONTH=2,9;BYMONTHDAY=1,2,3,4,5,6,7;BYDAY=SA,SU
which will be:
Sat 2014/Sept/6
Sat 2016/Feb/6
Sat 2016/Sep/3
...
Sun 2024/Sep/1
this was verified with dateutil-python and http://jkbr.github.io/,