Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

datebook

jshor70.1kMIT8.0.1TypeScript support: included

Generates URLs and ICS file content for adding events to popular calendar apps.

icalendar, google calendar, ics, yahoo calendar, outlook, calendar, event

readme

Datebook

A library for adding events to popular calendar apps.

It provides full support for rendering .ics file content for iCalendar and Office Outlook, and also supports URL generation for Google Calendar, Yahoo! Calendar, and Outlook Web.


Code coverage Build status npm version npm package size


Documentation

Read the docs →

Demo

Try the online calendar generator →

Quick Start

Installation

yarn add datebook

Examples

import { ICalendar } from 'datebook'

const config: CalendarOptions = {
  title: 'Happy Hour',
  location: 'The Bar, New York, NY',
  description: 'Let\'s blow off some steam with a tall cold one!',
  start: new Date('2022-07-08T19:00:00'),
  end: new Date('2022-07-08T23:30:00'),
  attendees: [
    {
      name: 'John Doe',
      email: 'john@doe.com',
      icsOptions: {
        rsvp: true
      }
    },
    {
      name: 'Jane Doe',
      email: 'jane@doe.com'
    }
  ],
  // an event that recurs every two weeks:
  recurrence: {
    frequency: 'WEEKLY',
    interval: 2
  }
}

const icalendar = new ICalendar(config)

iCalendar

With a reminder
icalendar
  .addAlarm({
    action: 'DISPLAY',
    description: 'Remember this event'
    trigger: {
      minutes: 10
    }
  })

This will add a reminder alarm that shows 10 minutes before the event.

With multiple events
const secondEvent = new ICalendar({
  title: 'Monthly Meeting with Boss Man',
  location: 'Conference Room 2A, Big Company, Brooklyn, NY',
  description: 'Meeting to discuss weekly things',
  start: new Date('2022-07-08T19:00:00'),
  recurrence: {
    frequency: 'MONTHLY'
  }
})

icalendar.addEvent(secondEvent)

This will add a second event to the same .ics file.

Adding other ICS properties
icalendar.addProperty('CATEGORIES', 'MEETINGS,MANAGEMENT')

This will add the CATEGORIES ICS property to the iCalendar instance.

Rendering ICS file content
const content = icalendar.render()

This will render ICS file content which can be downloaded onto the user's device for use in local calendar apps.

Google Calendar

const googleCalendar = new GoogleCalendar(config)

googleCalendar.render()

googleCalendar.render() will return a URL that the user can navigate to and pre-fill event details:

https://calendar.google.com/calendar/render?action=TEMPLATE&text=Happy%20Hour&details=Let's%20blow%20off%20some%20steam%20with%20a%20tall%20cold%20one!&location=The%20Bar%2C%20New%20York%2C%20NY&dates=20220708T190000%2F20220708T230000&recur=RRULE%3AFREQ%3DWEEKLY%3BINTERVAL%3D1

changelog

8.0.1 (2023-06-06)

Bug Fixes

  • updates types-directory in package.json #215 (df969e9)

8.0.0 (2023-01-10)

Features

  • ics: removes download() method (41ae072)

BREAKING CHANGES

  • ics: the download() method is now removed from ICalendar.

7.1.2 (2023-01-10)

Bug Fixes

  • exports ESM by default; clarifies UMD docs (17ccfe6)

7.1.1 (2023-01-09)

Bug Fixes

  • sets proper build extensions and branch refs (10522e2)

7.1.0 (2022-11-26)

Features

7.0.11 (2022-11-25)

Bug Fixes

7.0.10 (2022-11-25)

Bug Fixes

  • recurrence: adds missing months param (e84c73e)

7.0.9 (2022-11-25)

7.0.8 (2021-12-23)

Bug Fixes

  • ics: escapes special characters for text types (#183) (ca2f348)

7.0.7 (2021-10-21)

7.0.6 (2021-10-11)

7.0.5 (2021-10-11)

7.0.4 (2021-10-11)

7.0.3 (2021-10-11)

7.0.2 (2021-10-11)

7.0.1 (2021-08-28)

7.0.0 (2021-08-28)

Code Refactoring

  • yahoo: removes RPAT parameter (598a53d)

BREAKING CHANGES

  • yahoo: removes the ability to specify recurrences with Yahoo calendar as this ability has been removed by Yahoo.

6.5.9 (2021-08-28)

Bug Fixes

6.5.8 (2021-08-28)

Bug Fixes

6.5.7 (2021-06-29)

6.5.6 (2021-06-22)

6.5.5 (2021-06-04)

6.5.4 (2021-05-27)

6.5.3 (2021-05-04)

Bug Fixes

6.5.2 (2021-04-30)

6.5.1 (2021-03-24)

6.5.0 (2021-03-15)

Features

6.4.4 (2021-03-09)

6.4.3 (2021-03-02)

6.4.2 (2021-02-19)

6.4.1 (2021-02-19)

6.4.0 (2021-01-16)

Features

  • ics: adds setMeta method (2810148)

6.3.1 (2021-01-16)

Bug Fixes

  • types: corrects webpack types dist dir (#138) (a6a2fb5)

6.3.0 (2021-01-05)

Features

  • attendees: implements cross-calendar support (eabd3c1)
  • config: adds support for attendees (33b8f8e), closes #131

6.2.0 (2021-01-05)

Features

  • ics: allow providing .ics filename, without relying on title (9fc3314)
  • ics: allow providing .ics filename, without relying on title (ad356ed)

6.1.1 (2020-12-23)

6.1.0 (2020-12-21)

Features

  • params: adds ability to update cal params (59433ca)

6.0.4 (2020-12-12)

6.0.3 (2020-12-12)

6.0.2 (2020-10-27)

6.0.1 (2020-10-24)

6.0.0 (2020-10-24)

Features

  • ics: adds property management, alarms (d63c88a)
  • ics: implements support for multiple events (beda826)

BREAKING CHANGES

  • ics: renames IOptions to type CalendarOptions, IRecurrence to CalendarRecurrence.

5.0.7 (2020-10-24)

Bug Fixes

  • ics: adds proper detection for iOS Safari (754397c)

5.0.6 (2020-10-23)

5.0.5 (2020-10-19)

Bug Fixes

  • ics: corrects timestamp format for recurrences (497a97e)

5.0.4 (2020-10-19)

5.0.3 (2020-10-19)

5.0.2 (2020-09-28)

5.0.1 (2020-09-28)

5.0.0 (2020-09-28)

Code Refactoring

  • removes ability to specify time as strings (af23513)
  • removes calendars util (82e2516)

BREAKING CHANGES

  • Removes getGoogleCalendarUrl(), getYahooCalendarUrl(), getMicrosoftCalendarUrl(), and downloadIcs().
  • Removes ability to pass start, end, or recurrence.end as strings. They must now be passed as Date objects.

4.1.11 (2020-09-28)

Bug Fixes

  • outlook: prevents path from being encoded (#115) (f588947)

4.1.10 (2020-09-28)

Bug Fixes

4.1.9 (2020-09-26)

Bug Fixes

4.1.8 (2020-09-26)

Bug Fixes

4.1.7 (2020-09-26)

Bug Fixes

4.1.6 (2020-09-14)

Bug Fixes

4.1.3 (2020-06-12)

Bug Fixes

4.1.2 (2020-05-13)

Bug Fixes

  • timestamps: fixes calendar timestamp formats (#84) (#85) (0e41dd7)

4.1.1 (2020-04-29)

Bug Fixes

4.1.0 (2020-04-29)

Features

4.0.0 (2020-04-29)

Bug Fixes

  • bundle: replaces parcel with webpack to address UMD export issues (e4f7fc6)

Code Refactoring

  • converts component to be a vanilla js library (9a466aa)

BREAKING CHANGES

  • This is no longer an Angular.js component. It is now a pure JS library and will be incompatible with old usage.

1.3.5 (2019-06-10)

Features

  • core: adds core code for vanilla js lib (7b3c9d9)

1.1.6 (2016-06-28)

1.1.5 (2016-05-11)