Code Monkey home page Code Monkey logo

datebook's Introduction

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: '[email protected]',
      icsOptions: {
        rsvp: true
      }
    },
    {
      name: 'Jane Doe',
      email: '[email protected]'
    }
  ],
  // 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

datebook's People

Contributors

jshor avatar github-actions[bot] avatar csakai avatar dependabot[bot] avatar bignall avatar shmert avatar prystupa avatar eugenedw avatar sailor avatar eroself avatar ykhan21 avatar bekzod avatar ashleywchu avatar tiberiog avatar roberttaylor426 avatar tripflex avatar yaal avatar marcelo-lopes avatar buyachaka avatar lennertj avatar krisgardiner avatar celluj34 avatar crgeary avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.