ical-generator is a small piece of code which generates ical calendar files. I use this to generate subscriptionable calendar feeds.
npm install ical-generator
var ical = require('ical-generator'),
http = require('http'),
cal = ical();
cal.setDomain('sebbo.net').setName('my first iCal');
cal.addEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event',
description: 'It works ;)',
location: 'my room',
url: 'http://sebbo.net/'
});
http.createServer(function(req, res) {
cal.serve(res);
}).listen(3000, '127.0.0.1');
console.log('Server running at http://127.0.0.1:3000/');
Use this method to set your server's hostname. It will be used to generate the feed's UID. Default hostname is localhost.
Use this method to set your feed's name.
Use this method to set your feed's timezone.
This method is used to overwrite the default ProdID:
cal.setProdID({
company: 'My Company',
product: 'My Product',
language: 'EN'
});
Add an event. Options is an plain object, that configure the event.
Event UID. If not set, an UID will be generated randomly.
Appointment date of beginning
Appointment date of end
Appointment is a repeating event
cal.addEvent({
/* Other options */
repeating: {
freq: 'MONTHLY', // required
count: 5,
interval: 2,
until: new Date("Jan 01 2014 00:00:00 UTC")
}
});
Appointment is for the whole day
Appointment is a "floating" time. From section 3.3.12 of RFC 554:
Time values of this type are said to be "floating" and are not bound to any time zone in particular. They are used to represent the same hour, minute, and second value regardless of which time zone is currently being observed. For example, an event can be defined that indicates that an individual will be busy from 11:00 AM to 1:00 PM every day, no matter which time zone the person is in. In these cases, a local time can be specified.
Appointment date of creation
Appointment summary
Appointment description
Appointment location
Appointment organizer
cal.addEvent({
start: new Date(),
end: new Date(new Date().getTime() + 3600000),
summary: 'Example Event',
description: 'Appointment with Organizer',
location: 'Room 123',
organizer: {
name: 'Organizer\'s Name',
email: '[email protected]'
}
});
Appointment Website
Appointment method. May be any of the following: publish, request, reply, add, cancel, refresh, counter, declinecounter.
Appointment status. May be any of the following: confirmed, tenative, cancelled.
Save Calendar to disk asynchronously using fs.writeFile
Save Calendar to disk synchronously using fs.writeFileSync
Send Calendar to the User when using HTTP. See example above.
Return Calendar as a String.
Returns the ammount of events in the calendar.
Empty the Calender.
// simple unit tests
mocha -R spec
// coverage test
istanbul cover _mocha -- -R spec
Copyright (c) Sebastian Pekarek under the MIT license.