# RRule Plugin

> FullCalendar v5 documentation, for an old release. Web version: https://legacy.fullcalendar.io/v5/rrule-plugin
>
> Latest version (v7): https://fullcalendar.io/docs/rrule-plugin.md

The RRule plugin is a connector to the [rrule js library](https://github.com/jakubroztocil/rrule). It is powerful for specifying recurring events, moreso than FullCalendar's built-in [simple event recurrence](https://legacy.fullcalendar.io/v5/recurring-events.md).


## Usage with NPM

First, install the `@fullcalendar/rrule` package along with any other packages you plan to use:

```
npm install --save @fullcalendar/rrule @fullcalendar/core @fullcalendar/daygrid
```

Then, create a new calendar and pass in the plugins:

```js
import { Calendar } from '@fullcalendar/core'
import rrulePlugin from '@fullcalendar/rrule'
import dayGridPlugin from '@fullcalendar/daygrid'

let calendarEl = document.getElementById('calendar')
let calendar = new Calendar(calendarEl, {
  plugins: [ rrulePlugin, dayGridPlugin ],
  events: [
    // event data. see below
  ]
})

calendar.render()
```


## Usage with Script Tags

You can also configure the rrule plugin with [script tags](https://legacy.fullcalendar.io/v5/initialize-globals.md). The plugin is not part of the standard `fullcalendar` bundle, so add the rrule library and the plugin's own global file. This example leverages CDN links:

```html
<!-- rrule lib -->
<script src='https://cdn.jsdelivr.net/npm/rrule@2.6.4/dist/es5/rrule.min.js'></script>

<!-- fullcalendar bundle -->
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.5/main.min.js'></script>

<!-- the rrule-to-fullcalendar connector. must go AFTER the rrule lib and the fullcalendar bundle -->
<script src='https://cdn.jsdelivr.net/npm/@fullcalendar/rrule@5.11.5/main.global.min.js'></script>

<script>
  var calendarEl = document.getElementById('calendar')
  var calendar = new FullCalendar.Calendar(calendarEl, {
    events: [
      // event data. see below
    ]
  })

  calendar.render()
</script>
```

<a class='more-link' href='https://legacy.fullcalendar.io/v5/rrule-global-demo'>View a live demo</a>


## Event Data

When using the RRule plugin, [event parsing](https://legacy.fullcalendar.io/v5/event-parsing.md) accepts these new properties:

<table>
<tr>
<th>rrule</th>
<td markdown='1'>
Accepts whatever the rrule lib accepts for a `new RRule`. [See the RRule docs](https://github.com/jakubroztocil/rrule). You can specify a string or an object.
</td>
</tr>
<tr>
<th>exdate</th>
<td markdown='1'>
A [date input](https://legacy.fullcalendar.io/v5/date-parsing.md) or array of date inputs.
</td>
</tr>
<tr>
<th>exrule</th>
<td markdown='1'>
An object or array of objects. The object is whatever the `new RRule` constructor takes. [See the RRule docs](https://github.com/jakubroztocil/rrule).
</td>
</tr>
<tr>
<th>duration</th>
<td markdown='1'>
Must be something that [parses into a Duration](https://legacy.fullcalendar.io/v5/duration-object.md). If not specified, each event will appear to have the default duration. See [defaultAllDayEventDuration](https://legacy.fullcalendar.io/v5/defaultAllDayEventDuration.md), [defaultTimedEventDuration](https://legacy.fullcalendar.io/v5/defaultTimedEventDuration.md), and [forceEventDuration](https://legacy.fullcalendar.io/v5/forceEventDuration.md) for more info.
</td>
</tr>
</table>


## The `rrule` property

You can specify the `rrule` property as an object:

```js
var calendar = new FullCalendar.Calendar(calendarEl, {
  events: [
    {
      title: 'my recurring event',
      rrule: {
        freq: 'weekly',
        interval: 5,
        byweekday: [ 'mo', 'fr' ],
        dtstart: '2012-02-01T10:30:00', // will also accept '20120201T103000'
        until: '2012-06-01' // will also accept '20120201'
      }
    }
  ]
})
```

If you're specifying an object, you can write some of the properties in a way that's more convenient than what rrule requires. You don't need to use the RRule constants like `RRule.WEEKLY`. You can just specify the string `'weekly'`. This is better for JSON serialization.

You can also specify `rrule` as a string:

```js
var calendar = new FullCalendar.Calendar(calendarEl, {
  events: [
    {
      title: 'my recurring event',
      rrule: 'DTSTART:20120201T103000Z\nRRULE:FREQ=WEEKLY;INTERVAL=5;UNTIL=20120601;BYDAY=MO,FR'
    }
  ]
})
```


## Exclusion Properties

As of version `5.5.0`, you can supply properties that exclude certain dates generated by the previously supplied `rrule`. These only work if you're defining `rrule` as an object. If you're defining `rrule` as as string, you should write the exclusions within the string itself.

You can exclude one or more explicit dates using `exdate`:

```js
var calendar = new FullCalendar.Calendar(calendarEl, {
  events: [
    {
      title: 'my recurring event',
      rrule: {
        freq: 'weekly',
        dtstart: '2012-02-01'
      },
      exdate: ['2012-02-08'] // will also accept a single string
    }
  ]
})
```

Or, you can use a separate rrule to define the dates you want excluded, using `exrule`:

```js
var calendar = new FullCalendar.Calendar(calendarEl, {
  events: [
    {
      title: 'my recurring event',
      rrule: {
        freq: 'weekly',
        dtstart: '2012-02-01'
      },
      exrule: { // will also accept an array of these objects
        freq: 'weekly',
        dtstart: '2012-02-15',
        until: '2012-02-22'
      }
    }
  ]
})
```


## Times and Time Zones

The `dtstart` and `until` dates (or `DTSTART` and `UNTIL` when specifying a string) will be parsed in this way:

- If a time part is not specified (like `T10:30:00` or `T103000`), the event is assumed to be all-day.
- If a time zone part is not specified (like `Z`), the event will assume the [timeZone](https://legacy.fullcalendar.io/v5/timeZone.md) of the calendar.
