1.4.5 • Published 10 months ago

simple-rrule v1.4.5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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)


GitHub npm GitHub all releases npm bundle size npm bundle size GitHub contributors


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')
)

Good examples in 'test' folder.

rrule string fields


1.4.5

10 months ago

1.4.4

10 months ago

1.4.3

11 months ago

1.4.2

11 months ago

1.4.1

1 year ago

1.2.3

1 year ago

1.4.0

1 year ago

1.2.2

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago