Coder Social home page Coder Social logo

ical-generator's Introduction

ical-generator

Build Status

ical-generator is a small piece of code which generates ical calendar files. I use this to generate subscriptionable calendar feeds.

Installation

npm install ical-generator

Example

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/');

API

setDomain(domain)

Use this method to set your server's hostname. It will be used to generate the feed's UID. Default hostname is localhost.

setName(name)

Use this method to set your feed's name.

setProdID(prodID)

This method is used to overwrite the default ProdID:

cal.setProdID({
	company: 'My Company',
	product: 'My Product',
	language: 'EN'
});

addEvent(options)

Add an event. Options is an plain object, that configure the event.

options.uid (String)

Event UID. If not set, an UID will be generated randomly.

options.start (Date Object, required)

Appointment date of beginning

options.end (Date Object, required)

Appointment date of end

options.allDay (Bool)

Appointment is for the whole day

options.stamp (Date Object)

Appointment date of creation

options.summary (String, required)

Appointment summary

options.description (String)

Appointment description

options.location (String)

Appointment location

options.organizer (Plain Object)

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]'
	}
});

options.url (String)

Appointment Website

save(file[, cb])

Save Calendar to disk asynchronously using fs.writeFile

saveSync(file)

Save Calendar to disk synchronously using fs.writeFileSync

serve(response)

Send Calendar to the User when using HTTP. See example above.

toString()

Return Calendar as a String.

length()

Returns the ammount of events in the calendar.

clear()

Empty the Calender.

Tests

// simple unit tests
mocha -R spec

// coverage test
istanbul cover _mocha -- -R spec

ical-generator's People

Contributors

sebbo2002 avatar kesla avatar notthetup avatar spruce avatar gausie avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.