/ics.js

JS implementation of RFC 5545 (iCalendar).

Primary LanguageJavaScriptMIT LicenseMIT

ics.js

Build Status NPM Version License

Pure JavaScript implementation of RFC 5545 (iCalendar).

Project Status : Paused. I may work on it later but I don't have the time for now.

Overview

Goals

  • Being able to generate and fully parse iCal files.
  • Pure JavaScript (ES5, strict mode) with no runtime dependencies.
  • Node.js and browser compatibility.

Installation

Node.js

You can install it locally:

$ npm install icsjs

or you can add it as a dependency in your package.json:

{ "dependencies" :
  {
    "icsjs" : "0.x"
  }
}

Then you just have to require it in your code:

var iCalendar = require('icsjs');

Browser

You just have to include it in your HTML:

<script src="path/to/ics.js"></script>

and it will automatically expose the iCalendar object.

Usage

Annotated source

Creating a calendar

// Let's do a party right now.
var party = new iCalendar.EventBuilder();

party.setStartDate(new Date());
party.setDuration('PT3H0M0S');

party.setSummary('Crazy party at the beach');

// But don't forget tommorow's meeting.
var meeting = new iCalendar.EventBuilder();
var tommorow = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);

meeting.setStartDate(tommorow);
meeting.setDuration('PT1H0M0S');

meeting.setSummary("Financial result's presentation");

// Put that together in our calendar.
var calendar = new iCalendar.CalendarBuilder();
calendar.addEvent(party.getEvent());
calendar.addEvent(meeting.getEvent());

// And display it.
console.log(calendar.getCalendar().toString());