Awesome ICS

v0.1.0

The library is designed for developers who want to support iCalendar functionality directly in their nodejs code. The code is written in ES6 and then transformed to ES5 with the use of Babel. The objects were designed according to rfc5545 standard specification.

Installation

npm install --save awesome-ics

Usage

Create calendar

var AwesomeICS  = require("awesome-ics");
var moment      = require("moment");

var summary     = new AwesomeICS.PropertyValue.Text().setValue("Christmas Eve");
var description = new AwesomeICS.PropertyValue.Text().setValue("Please, remember about Christmas Eve");
var dateStart   = new AwesomeICS.PropertyValue.DateTime().setDateValue(moment("2015-12-24"))
                    .setTimeValue(moment("18:00", "HH:mm"))
                    .setIsFixedValue(true);
var dateEnd     = new AwesomeICS.PropertyValue.DateTime().setDateValue(moment("2015-12-26"))
                    .setTimeValue(moment("23:59", "HH:mm"))
                    .setIsFixedValue(true);


var calendar = new AwesomeICS.Calendar()
    .addBlock(
        new AwesomeICS.Block()
            .setType("VEVENT")
            .addProperty(new AwesomeICS.Property().setName("DESCRIPTION").setValue(description))
            .addProperty(new AwesomeICS.Property().setName("DTSTART").setValue(dateStart))
            .addProperty(new AwesomeICS.Property().setName("DTEND").setValue(dateEnd))
            .addProperty(new AwesomeICS.Property().setName("SUMMARY").setValue(summary)));

Read from file

var AwesomeICS  = require("awesome-ics");
var fs          = require("fs");

var icsFile  = fs.readFileSync("./ics/my-file.ics", "utf8").trim();
var calendar = new AwesomeICS.Calendar().convertFromString(icsFile);

calendar.toString()

calandar.toString();
/*
BEGIN:VCALENDAR
BEGIN:VEVENT
DESCRIPTION:Please, remember about Christmas Eve
DTSTART:20151224T180000
DTEND:20151226T235900
SUMMARY:Christmas Eve
END:VEVENT
END:VCALENDAR
*/

calendar.toJSON()

calandar.toJSON();
/*
{
    "type": "VCALENDAR",
    "properties": [],
    "blocks": [
        {
            "type": "VEVENT",
            "properties": [
                {
                    "name": "DESCRIPTION",
                    "parameters": [],
                    "value": "Please, remember about Christmas Eve"
                },
                {
                    "name": "DTSTART",
                    "parameters": [],
                    "value": {
                        "date": "20151224",
                        "time": {
                            "isFixed": true,
                            "time": "180000"
                        }
                    }
                },
                {
                    "name": "DTEND",
                    "parameters": [],
                    "value": {
                        "date": "20151226",
                        "time": {
                            "isFixed": true,
                            "time": "235900"
                        }
                    }
                },
                {
                    "name": "SUMMARY",
                    "parameters": [],
                    "value": "Christmas Eve"
                }
            ],
            "blocks": []
        }
    ]
}
*/

Details

Library content

var AwesomeICS  = require("awesome-ics");
/*
AwesomeICS.Calendar
AwesomeICS.Block
AwesomeICS.Property
AwesomeICS.PropertyParameter
AwesomeICS.PropertyValue.Value
AwesomeICS.PropertyValue.MultipleValue
AwesomeICS.PropertyValue.Binary
AwesomeICS.PropertyValue.Boolean
AwesomeICS.PropertyValue.CalendarUserAddress
AwesomeICS.PropertyValue.Date
AwesomeICS.PropertyValue.DateTime
AwesomeICS.PropertyValue.Duration
AwesomeICS.PropertyValue.Float
AwesomeICS.PropertyValue.Geo
AwesomeICS.PropertyValue.Integer
AwesomeICS.PropertyValue.PeriodOfTime
AwesomeICS.PropertyValue.RecurrenceRule
AwesomeICS.PropertyValue.Text
AwesomeICS.PropertyValue.Time
AwesomeICS.PropertyValue.URI
AwesomeICS.PropertyValue.UTCOffset
*/

Documentation