simple-rrule
v1.4.5
Published
simple rrule string parser and expand date events
Downloads
11
Readme
simple-rrule.js
Simple recurrence rules to get scheduler events for calendar dates.
simple-rrule.js expands recurrence dates from a rrule string.
rules as defined in the iCalendar RFC (with partial implementation)
rrule.js supports recurrence rules as defined in the iCalendar
RFC, with a few important
differences. It is a partial port of the
rrule
module from the excellent
python-dateutil library. On top of
that, it supports parsing and serialization of recurrence rules from and
to natural language.
Quick Start
Includes optional TypeScript types
$ yarn add simple-rrule
# or
$ npm install simple-rrule
Example 1
import { expandRRuleFromString } from 'simple-rrule'
const rRule =
'DTSTART:20221215T100000Z\nRRULE:FREQ=YEARLY;BYDAY=MO;BYMONTH=1;BYSETPOS=2;COUNT=5;WKST=SU'
const rRule = `DTSTART:DTSTART:20221215T100000Z\nRRULE:FREQ=DAILY;INTERVAL=1;COUNT=3;WKST=SU`
const r = expandRRuleFromString(rRule, today, addDays(today, 3))
Example 2
import { parseRecurrenceFromString, expandRRule, WeekDay } from 'simple-rrule'
const rRule =
'DTSTART:20221216T100000Z\nRRULE:FREQ=MONTHLY;INTERVAL=1;BYSETPOS=2;BYDAY=WE;UNTIL=20230411T100000Z;WKST=SU'
const rRule = await parseRecurrenceFromString(rRule, Weekday.Sunday)
console.log(rRule)
const r = expandRRule(
rRule,
new Date('2023-02-02T10:00:00.000Z'),
new Date('2023-12-31T10:00:00.000Z')
)
Example 3
import { expandRRuleFromString } from 'simple-rrule'
const rRule =
'DTSTART:20221215T100000Z\nRRULE:FREQ=YEARLY;BYDAY=MO;BYMONTH=1;BYSETPOS=2;COUNT=5;WKST=SU'
const r = expandRRuleFromString(
rRule,
new Date('2023-01-28T10:00:00.000Z'),
new Date('2025-05-31T10:00:00.000Z')
)
Example 4
import { expandRRuleFromString } from 'simple-rrule'
const rRule =
'DTSTART:20221215T100000Z\nRRULE:FREQ=YEARLY;BYDAY=MO;BYMONTH=1;BYSETPOS=2;COUNT=5;WKST=SU'
const r = expandRRuleFromString(
rRule,
new Date('2023-01-28T10:00:00.000Z'),
new Date('2025-05-31T10:00:00.000Z')
)