ICal Toolkit NodeJS
ICal generator/updater/parser with Timezone/DST, Alams, Organizers, Events, etc. support.
100% JavaScript implementation.
Ical generator supports the following:
- VTIMEZONE - TIMEZONE/DST info. We have inbuilt timezone database, you just specify TimeZone ID and rest module will take care.
- Alarms
- Attendees info and state per event.
- Organizers
- Multiple events
- Full day and repeating events
- URL property
- Simple intuitive interface.
Install
> npm install ical-toolkit
Builder
Quick documentation, but covers all and will get you going quick!
Values to use:
Here are the constants you can use:
Attendee Role
"REQ-PARTICIPANT"; Indicates a participant whose
; participation is required
"OPT-PARTICIPANT" ; Indicates a participant whose
; participation is optional
"NON-PARTICIPANT" ; Indicates a participant who is
; copied for information purposes only
Attendee Status
"NEEDS-ACTION" ; Event needs action
"ACCEPTED" ; Event accepted
"DECLINED" ; Event declined
"TENTATIVE" ; Event tentatively accepted
"DELEGATED" ; Event delegated
Methods
'PUBLISH',
'REQUEST',
'REPLY',
'ADD',
'CANCEL',
'REFRESH',
'COUNTER',
'DECLINECOUNTER'
Repeating Freq for event
'SECONDLY',
'MINUTELY',
'HOURLY',
'DAILY',
'WEEKLY',
'MONTHLY',
'YEARLY'
Statuses for event
'CONFIRMED',
'TENTATIVE',
'CANCELLED'
Demo code, shows all.
var icalToolkit = ; //Create a buildervar builder = icalToolkit; /* * Settings (All Default values shown below. It is optional to specify) * */builderspacers = true; //Add space in ICS file, better human reading. Default: truebuilderNEWLINE_CHAR = '\r\n'; //Newline char to use.builderthrowError = false; //If true throws errors, else returns error when you do .toString() to generate the file contents.builderignoreTZIDMismatch = true; //If TZID is invalid, ignore or not to ignore! /** * Build ICS * */ //Name of calander 'X-WR-CALNAME' tag.buildercalname = 'Yo Cal'; //Cal timezone 'X-WR-TIMEZONE' tag. Optional. We recommend it to be same as tzid.buildertimezone = 'america/new_york'; //Time Zone ID. This will automatically add VTIMEZONE info.buildertzid = 'america/new_york'; //Methodbuildermethod = 'REQUEST'; //Add eventsbuilderevents; //Optional tags on VCALENDAR level if you intent to add. Optional fieldbuilderadditionalTags = 'SOMETAG': 'SOME VALUE'; //Try to buildvar icsFileContent = builder; //Check if there was an error (Only required if yu configured to return error, else error will be thrown.)if icsFileContent instanceof Error console; //handle error //Here isteh ics file content.console;
Output####
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
X-WR-CALNAME:Yo Cal
METHOD:REQUEST
PRODID:node-ical-toolkit
X-WR-TIMEZONE:asia/kalcutta
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:f0e532a3
DTSTAMP:20150707T070727Z
TRANSP:OPAQUE
DTSTART;VALUE=DATE:20150707
DTEND;VALUE=DATE:20150707
SUMMARY:Test Event
SEQUENCE:0
LOCATION:Home
DESCRIPTION:Testing it!
URL;VALUE=URI:http://google.com
STATUS:CONFIRMED
ORGANIZER;SENT-BY="MAILTO:[email protected]":CN="Kushal Likhi":mailto:test@mail
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;RSVP=TRUE;CN=A1:MAILTO:[email protected]
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=A2:MAILTO:[email protected]
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
END:VALARM
BEGIN:VALARM
TRIGGER:-PT10M
ACTION:DISPLAY
END:VALARM
BEGIN:VALARM
TRIGGER:-PT5M
ACTION:DISPLAY
END:VALARM
RRULE:FREQ=DAILY;COUNT=10;INTERVAL=10;UNTIL=20150707T070727Z
SOMETAG:SOME VALUE
END:VEVENT
SOMETAG:SOME VALUE
END:VCALENDAR
Parser##
Parse the ics files to JSON structures
; ; ; ;