Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rrule

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrule

JavaScript library for working with recurrence rules for calendar dates.

  • 2.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
609K
decreased by-4.65%
Maintainers
2
Weekly downloads
 
Created

What is rrule?

The 'rrule' npm package is a powerful library for working with recurrence rules as defined in the iCalendar RFC. It allows you to generate and manipulate recurring dates with a high degree of flexibility and precision.

What are rrule's main functionalities?

Generating Recurrence Rules

This feature allows you to generate a set of recurring dates based on a specified rule. In this example, the rule generates dates that occur weekly on Mondays and Fridays, starting from January 1, 2023, and ending on June 1, 2023.

const { RRule } = require('rrule');

const rule = new RRule({
  freq: RRule.WEEKLY,
  interval: 1,
  byweekday: [RRule.MO, RRule.FR],
  dtstart: new Date(Date.UTC(2023, 0, 1, 10, 30)),
  until: new Date(Date.UTC(2023, 5, 1))
});

console.log(rule.all());

Parsing Recurrence Rules

This feature allows you to parse a recurrence rule from a string in the iCalendar format. The example demonstrates how to parse a rule string and generate the corresponding dates.

const { RRule } = require('rrule');

const ruleString = 'FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,FR;DTSTART=20230101T103000Z;UNTIL=20230601T000000Z';
const rule = RRule.fromString(ruleString);

console.log(rule.all());

Converting Recurrence Rules to String

This feature allows you to convert a recurrence rule to its string representation in the iCalendar format. The example shows how to create a rule and then convert it to a string.

const { RRule } = require('rrule');

const rule = new RRule({
  freq: RRule.WEEKLY,
  interval: 1,
  byweekday: [RRule.MO, RRule.FR],
  dtstart: new Date(Date.UTC(2023, 0, 1, 10, 30)),
  until: new Date(Date.UTC(2023, 5, 1))
});

console.log(rule.toString());

Handling Timezones

This feature allows you to handle timezones when working with recurrence rules. The example demonstrates how to create a rule and add it to a rule set, which can then be used to generate dates considering timezones.

const { RRule, RRuleSet, rrulestr } = require('rrule');

const rule = new RRule({
  freq: RRule.WEEKLY,
  interval: 1,
  byweekday: [RRule.MO, RRule.FR],
  dtstart: new Date(Date.UTC(2023, 0, 1, 10, 30)),
  until: new Date(Date.UTC(2023, 5, 1))
});

const ruleSet = new RRuleSet();
ruleSet.rrule(rule);

console.log(ruleSet.all());

Other packages similar to rrule

Keywords

FAQs

Package last updated on 10 Nov 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc