Closed nhaberl closed 4 years ago
The recurrence can exclude holidays if you set the CanOccurOnHolidays property to false and define the holidays in the Holidays property. It cannot exclude instances from other recurrences though.
However, you can use a VEvent instance from the calendaring classes to do that as it does support it. You'd add the recurrence used to generate the task dates to the RecurrenceRules property and the recurrence used to generate the dates on which it should not occur to the ExceptionRules property. In both cases, you'd create an instance of the rule property and use its Recurrence
property to define the recurrence settings.
The VEvent
class has a set of methods similar to the recurrence class that can be used to find instances (AllInstances
, InstancesBetween
, LastInstance
, and OccursOn
). Those all take into account the defined recurrence and exception rules as well as specific dates to include or exclude (ExceptionDates
and RecurDates
).
Thanks a lot, this makes sense! Can I also set a range as exceptional ?
Additionallly ... how does your lib handle changes of start / end dates ? I have seen RECURRENCE-ID but no idea how I can change several events out of a recurring event ?
As noted, the exceptions can be set as one or more recurrence rules or as individual dates. You can use either to define a range.
If you change the StartDateTime
property on the event, it changes the base date for the recurrence rules. If you want to adjust individual instances of a recurrence, similar to moving an appointment on a calendar based on a recurrence, you could add an exception date to exclude the original and a recur date to indicate the date to which it was moved.
Hi,
would it be possible to define holidays as ranges so when generating the occurance pattern all dates are excluded which are in the "holiday / exception date ranges"?
Use case would be the following ... you define a monthly task on 15th but on yearly base you would like to do a special task (which includes all tasks from monthly) but I want that the monthly task does not show up when yearly is due.
So I would like to define yearly pattern of 20 th December (plus / minus 10 days) and when monthly falls into that range it gets included like the holidays.
Would be an awesome feature and maybe it can be done anyhow but couldn't find a way ... it's of real benefit when thinking of maintenance tasks