2

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"
}
ADyson
  • 57,178
  • 14
  • 51
  • 63
DeanO
  • 93
  • 1
  • 10

5 Answers5

4

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.

DeanO
  • 93
  • 1
  • 10
  • 1
    I'm going to assume this has just saved me 3 days. I'm in great debt to you. – jiroch Sep 30 '20 at 11:13
  • Beware, there's currently a bug in fullcalendar/rrule connector that causes multiple EXDATEs to not work properly if you supply the dates in UTC format (trailing Z). See https://github.com/fullcalendar/fullcalendar/issues/5726 – jiroch Sep 30 '20 at 12:52
  • Man, you saved me quite some time and nerves! – Stiropor Nov 06 '20 at 09:00
  • 1
    @jiroch adding the 'Z' char for RRule datetimes now works in v5.4.0 https://github.com/fullcalendar/fullcalendar/issues/5726 – Kyle Ordona Nov 14 '20 at 10:52
  • What do you mean `for each date you want to exclude`? So you're saying that if I want to exclude 05/03/2021 then that date has to be there twice? If so, in your example I only see one per date: `20190614T120000Z` and `20190628T120000Z`, which don't match. – Philll_t Feb 26 '21 at 18:10
2

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

Dany Dhondt
  • 881
  • 9
  • 27
  • 1
    Full Calendar also accepts an object instead of a string. Can you provide an example of how we would implement it in that form with multiple dates? – Philll_t Nov 22 '19 at 00:52
  • Beware, there's currently a bug in fullcalendar/rrule connector that causes multiple EXDATEs to not work properly if you supply the dates in UTC format (trailing Z). See https://github.com/fullcalendar/fullcalendar/issues/5726 – jiroch Sep 30 '20 at 12:53
2

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

Kyle Ordona
  • 271
  • 3
  • 5
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"
Arnaud Quillaud
  • 4,420
  • 1
  • 12
  • 8
  • I can't see how this is any better than the OP's code, or why it would be valid. I highly doubt that the RRULE format has newline (`\n`) characters as an accepted separator. All you've done is replace `;` with `\n` which I doubt is valid. I don't know the format that well, but it doesn't look meaningful. Can you explain the difference between a "property" and a "parameter" in RRULE, exactly? – ADyson Jun 14 '19 at 09:56
  • 1
    OK it looks like it is more of an rrule.js issue than a fullcalendar issue. The rrule plugin being used throws an error Unknown RRULE property 'EXDATE'. It also does this on the rrule demo page http://jakubroztocil.github.io/rrule/ if you try entering FREQ=WEEKLY;DTSTART=20190607T090000;EXDATE=20190705T090000;INTERVAL=4;BYDAY=FR as a text string, you get the same error. – DeanO Jun 14 '19 at 12:53
  • 1
    @ADyson Both RRULE and EXDATE are defined as properties by RFC5545. See https://tools.ietf.org/html/rfc5545#section-3.8.5.3 and https://tools.ietf.org/html/rfc5545#section-3.8.5.1 for their respective definitions as well as https://tools.ietf.org/html/rfc5545#section-3.2 to help you understand what this is all about. In the original post, the EXDATE is made a parameter of RRULE instead of a property in its own right. Then if you look at https://fullcalendar.io/docs/rrule-plugin you will see that multiple properties can be specified in the rrule, separated by \n – Arnaud Quillaud Jun 15 '19 at 09:38
  • 1
    Unfortunately, it looks like only the DTSTART property can be specified in rrule and no recurrence related properties (EXDATE or RDATE). – Arnaud Quillaud Jun 15 '19 at 09:45
  • 3
    Looking at the docs on https://github.com/jakubroztocil/rrule, I'm assuming that I have to use the RRuleSet Constructor ie. RRuleSet.prototype.exdate(dt) to set each EXDATE, but I have no idea where to do that in the fullCalendar code – DeanO Jun 15 '19 at 13:04
0

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Are you sure about this? When i try parse a RRULE with an EXDATE it says EXDATE is an invalid property. – Piotr Stulinski Dec 06 '20 at 04:22
  • When i save the string and try have fullcalendar use that string at a later stage i get the following: Unsupported RFC prop EXDATE in EXDATE:20201109T210000Z,20201123T210000Z. Fullcalendar cannot parse these EXDATES at a later stage. See https://github.com/jakubroztocil/rrule/issues/335 and https://github.com/fullcalendar/fullcalendar/issues/4549 – Piotr Stulinski Dec 06 '20 at 04:35
  • Use RRuleSet not RRule and make sure you are using full calendar version 5.4.0 – Jay Mancini Dec 07 '20 at 05:10
  • i have a whole bunch of JSON event data with the EXDATE in it. When i send this to fullcalendar it throws an error saying EXDATE is invalid. How are you getting RRuleSet into Fullcalendar 5.4.0? – Piotr Stulinski Dec 09 '20 at 12:36
  • @PiotrStulinski Post a sample of your RRULE and I'll have a look – DeanO Dec 11 '20 at 00:20
  • My issue was as follows - time portion of EXDATE was different which does not work, secondly the EXDATE must be on a newline. Thanks for the responses. – Piotr Stulinski Dec 12 '20 at 03:37