Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a recurring calendar event that happens on the 4th Friday of every month and I want to exclude 1 Friday event. I've tried
EXDATE
but I'm getting an error
Failure passing JSON
Without
EXDATE
the rrule works fine.
Here are the details that I'm using in Full Calendar to produce the event
start: "2019-07-06T09:00:00+10:00",
end: "2019-07-06T15:00:00+10:00",
rrule: "FREQ=WEEKLY;DTSTART=20190607T090000;EXDATE=20190705T090000;INTERVAL=4;BYDAY=FR",
title: "Weed Spraying",
description: "June, Harry, Pat, George, Valda, Helen, Karen, Ken",
color: "red",
url: "./?action=detail_view&id=22",
duration: "06:00"
OK I worked it out, @Arnaud is right, RRULE, EXDATE and DTSTART are properties not parameters of rrule, BUT they do go in the rrule property for FullCalendar with a \n newline, they also require a : NOT =. Example
rrule: 'DTSTART:20190308T120000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220330\nEXDATE:20190614T120000Z\nEXDATE:20190628T120000Z'
Notice how there are 2 EXDATE properties, for each date you want to exclude, you need to put an EXDATE.
I spent 3 days trying to get this to work, hopefully this will help save someone else time.
–
–
–
It is possible to add exceptions. You just need to format the RRule string correct:
DTSTART:20190610T103000\nRRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20190801\nEXDATE:20190618T103000Z\nEXDATE:20190619T103000
Watch this code sandbox for a demo
–
–
This format can also be used for multiple EXDATE:
rrule: "DTSTART:20201114T000000Z\nRRULE:FREQ=WEEKLY\nEXDATE:20201121T000000Z,20201128T000000Z"
This string was formatted using rruleSet.exdate(new Date(Date.UTC(2012, 5, 1, 10, 30)))
from rrule.js library to add multiple EXDATE in the rrule object then using the method .toString()
Also, note that adding the 'Z' char for RRule datetimes now works in v5.4.0
Do not know much about this particular JSON format but the EXDATE is a property, not a parameter of RRULE.
Please try
rrule: "FREQ=WEEKLY;DTSTART=20190607T090000;INTERVAL=4;BYDAY=FR\nEXDATE=20190705T090000"
–
–
–
–
–
In the latest version 5.4.0 the following code will work:
DTSTART:20201101T040000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
EXDATE:20201110T040000Z,20201124T040000Z
FullCalendar now supports multiple exdate
I used the RRule and RRuleSet to produce the rrule string:
*NOTE: You will have to be careful with daylight savings. That's why I had to adjust a couple of times. Do not focus on my specific date object. This is just an example of the solution to support multiple exdates using RRuleSet and RRule.
const rruleSet = new RRuleSet();
rruleSet.rrule(new RRule({
freq: Frequency.WEEKLY,
interval: 1,
byweekday: [RRule.TU],
dtstart: new Date(2020, 10, 1, 0, 0, 0, 0)
rruleSet.exdate(new Date(2020, 10, 9, 23, 0, 0, 0));
rruleSet.exdate(new Date(2020, 10, 23, 23, 0, 0, 0));
console.log(rruleSet.toString());
Here is the issue number:
https://github.com/fullcalendar/fullcalendar/issues/5726
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.