🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

simple-rrule

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-rrule

simple rrule string parser and expand date events

1.4.5
latest
Source
npm
Version published
Weekly downloads
39
875%
Maintainers
1
Weekly downloads
 
Created
Source

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

FieldTypeRequiredDefaultDescription
dtStartDateYThe recurrence start.
dtEndDateYUsed for duration (dtStart-dtEnd)
frequencyFrequency as StringY
  • Frequency.YEARLY
  • Frequency.MONTHLY
  • Frequency.WEEKLY
  • Frequency.DAILY
  • Frequency.HOURLY
  • Frequency.MINUTELY
  • Frequency.SECONDLY
intervalPositive IntegerY1The interval between each freq iteration
wkstWeekday as StringY'SU'The week start day.
countPositive IntegerNHow many occurrences will be generated.
untilDateNEnd limit of recurrence dates generated.
bydayWeekDay[] as StringNWeekday or WeekDays ex: 'SU' or 'SU,MO,FR'
bysetposIntegerNUsed only in byMonth and byYear
bymonthIntegerNMonth
bymonthdayIntegerNMonth day

FAQs

Package last updated on 12 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts