forked from kewisch/ical.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating basic iCalendar
Philipp Kewisch edited this page Apr 20, 2015
·
1 revision
Start off creating the basic data structure and set a property on that:
var comp = new ICAL.Component(['vcalendar', [], []]);
comp.updatePropertyWithValue('prodid', '-//iCal.js Wiki Example');
You can get the resulting iCalendar by calling comp.toString() at any time:
comp.toString();
// BEGIN:VCALENDAR
// PRODID:-//iCal.js Wiki Example
// END:VCALENDAR
Sub-components are created as needed and attached to the appropriate place in the "tree":
var vevent = new ICAL.Component('vevent'),
event = new ICAL.Event(vevent);
// Set some properties
event.summary = 'foo bar';
event.uid = 'abcdef...';
event.dtstamp = ICAL.Time.now(); // Can give it instances of appropriate types
// Add the new component
comp.addSubcomponent(vevent);
Printing the full calendar now:
comp.toString()
// BEGIN:VCALENDAR
// PRODID:-//iCal.js Wiki Example
// BEGIN:VEVENT
// SUMMARY:foo bar
// UID:abcdef...
// DTSTAMP:20131126T110632Z
// END:VEVENT
// END:VCALENDAR