0

Looking at this answer, it is shown how to include EXDATE in the string format option in FullCalendar.

But FullCalendar provides a convenient alternative to the long string. They allow you to use an object instead. Unfortunately their documentation doesn't really cover anything beyond that:

The rrule property accepts whatever the rrule lib accepts for a new RRule. See the docs. You can specify a string or an object.

The events we use are pretty heavy already and I would love to avoid adding additional complexity that would involve me writing some kind of mapper to generate this string.

I would like to know how to be able to exclude a list a of dates from a recurrence rule using the object format.

I've tried providing a date object of the specific date. I've tried providing an ISO string. I've tried including them in an array.

Update

This is the latest iteration that I'm trying:

...
 const rruleSet = new RRuleSet();

 rruleSet.rrule(new RRule(options));
 // Repeat every day except on Nov 22, 2019
 rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));

 event.duration = {
    seconds: event.event_length,
 };

 event.rrule = rruleSet.toString();
...

This renders the recurring dates (time is a little off) but the date that I'm trying to exclude still renders.

Philll_t
  • 4,267
  • 5
  • 45
  • 59

1 Answers1

3

In order for your exclusion rule to match the generated event, you must include the specific time as well. I expect this is because if you had events repeating multiple times in the day it wouldn't know which one you were trying to exclude.

(If your events were "all-day" style events, without a specific start time, then setting just the date in exdate would be ok.)

Therefore, changing

rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));

to

rruleSet.exdate(new Date(Date.UTC(2019, 10, 22, 10, 30)));

will solve your problem

Demo: https://codepen.io/ADyson82/pen/jOORaOZ

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • I ended up having to use this here. Turns out the object is only for the options. Any complexity beyond that you'll need to use the rruleset class to generate the string. – Philll_t Nov 26 '19 at 01:26
  • @Philll_t yes it looks like fullCalendar only accepts RRule objects, not RRuleSet objects for some reason, but it will accept a string containing all the possible options from both. No idea why that is. Glad it helped you anyway – ADyson Nov 26 '19 at 09:41