Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Use this method to set your feed's timezone. Is used to fill `TIMEZONE-ID` and `X-WR-TIMEZONE` in your iCal.
```javascript
varcal=ical().timezone('Europe/Berlin');
```
#### method([_String_ method])
Calendar method. May be any of the following: `publish`, `request`, `reply`, `add`, `cancel`, `refresh`, `counter`, `declinecounter`.
#### ttl([_Number_ ttl])
Use this method to set your feed's time to live. Is used to fill `REFRESH-INTERVAL` and `X-PUBLISHED-TTL` in your iCal.
```javascript
varcal=ical().ttl(60*60*24);
```
#### createEvent([_Object_ options])
Creates a new [Event](#event)([`ICalEvent`](#event)) and returns it. Use options to prefill the event's attributes.
Calling this method without options will create an empty event.
```javascript
varical=require('ical-generator'),
cal=ical(),
event=cal.createEvent({summary:'My Event'});
// overwrite event summary
event.summary('Your Event');
```
#### events([_Object_ events])
Add Events to calendar or return all attached events.
```javascript
varcal=ical();
cal.events([
{
start:newDate(),
end:newDate(newDate().getTime()+3600000),
summary:'Example Event',
description:'It works ;)',
url:'http://sebbo.net/'
}
]);
cal.events();// --> [ICalEvent]
```
#### save(**_String_ file**[, _Function_ cb])
Save Calendar to disk asynchronously using [fs.writeFile](http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback).
#### saveSync(**_String_ file**)
Save Calendar to disk synchronously using [fs.writeFileSync](http://nodejs.org/api/fs.html#fs_fs_writefilesync_filename_data_options).
#### serve(**_http.ServerResponse_ response**)
Send Calendar to the User when using HTTP. See Quick Start above.
#### toString()
Return Calendar as a String.
#### toJSON()
Return a shallow copy of the calendar's options for JSON stringification. Can be used for persistance.
```javascript
varcal=ical(),
json=JSON.stringify(cal);
// later
cal=ical(json);
```
#### length()
Returns the ammount of events in the calendar.
#### clear()
Empty the Calender.
### Event
#### uid([_String_|_Number_ uid]) or id([_String_|_Number_ id])
Use this method to set the event's ID. If not set, an UID will be generated randomly. When output, the ID will be suffixed with '@' + your calendar's domain.
#### sequence([_Number_ sequence])
Use this method to set the event's revision sequence number of the
calendar component within a sequence of revisions.
#### start([_Date_ start])
Appointment date of beginning as Date object. This is required for all events!
#### end([_Date_ end])
Appointment date of end as Date object.
#### timezone([_String_ timezone])
Use this method to set your event's timezone using the TZID property parameter on start and end dates, as per [date-time form #3 in section 3.3.5 of RFC 554](https://tools.ietf.org/html/rfc5545#section-3.3.5).
This and the 'floating' flag (see below) are mutually exclusive, and setting a timezone will unset the 'floating' flag. If neither 'timezone' nor 'floating' are set, the date will be output with in UTC format (see [date-time form #2 in section 3.3.5 of RFC 554](https://tools.ietf.org/html/rfc5545#section-3.3.5)).
#### timestamp([_Date_ stamp]) or stamp([_Date_ stamp])
Appointment date of creation as Date object. Default to `new Date()`.
#### allDay([_Boolean_ allDay])
When allDay == true -> appointment is for the whole day
#### floating([_Boolean_ floating])
Appointment is a "floating" time. From [section 3.3.12 of RFC 554](https://tools.ietf.org/html/rfc5545#section-3.3.12):
> 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.
This and the 'timezone' setting (see above) are mutually exclusive, and setting the floating flag will unset the 'timezone'. If neither 'timezone' nor 'floating' are set, the date will be output with in UTC format (see [date-time form #2 in section 3.3.5 of RFC 554](https://tools.ietf.org/html/rfc5545#section-3.3.5)).
#### repeating([_Object_ repeating])
Appointment is a repeating event
```javascript
event.repeating({
freq:'MONTHLY',// required
count:5,
interval:2,
until:newDate('Jan 01 2014 00:00:00 UTC'),
byDay:['su','mo'],// repeat only sunday and monday
byMonth:[1,2],// repeat only in january und february,
byMonthDay:[1,15],// repeat only on the 1st and 15th
exclude:[newDate('Dec 25 2013 00:00:00 UTC')]// exclude these dates
});
```
#### summary([_String_ summary])
Appointment summary, defaults to empty string.
#### description([_String_ description])
Appointment description
#### htmlDescription([_String_ htmlDescription])
Some calendar apps may support HTML descriptions. Like in emails, supported HTML tags and styling is limited.
#### location([_String_ location])
Appointment location
#### organizer([_String_|Object organizer])
Appointment organizer
```javascript
cal.organizer({
name:'Organizer\'s Name',
email:'organizer@example.com'
});
// OR
cal.organizer('Organizer\'s Name <organizer@example.com>');
```
#### createAttendee([_Object_ options])
Creates a new [Attendee](#attendee)([`ICalAttendee`](#attendee)) and returns it. Use options to prefill the attendee's attributes.
Calling this method without options will create an empty attendee.
Add alarms to the event or return all attached alarms.
```javascript
varevent=ical().createEvent();
cal.alarms([
{type:'display',trigger:600},
{type:'audio',trigger:300}
]);
cal.alarms();// --> [ICalAlarm, ICalAlarm]
```
#### url([_String_ url])
Appointment URL
#### status([_String_ status])
Appointment status. May be any of the following: `confirmed`, `tentative`, `cancelled`.
### Attendee
#### name([_String_ name])
Use this method to set the attendee's name.
#### email([_String_ email])
The attendee's email address. An email address is required for every attendee!
#### role([_String_ role])
Set the attendee's role, defaults to `REQ-PARTICIPANT`. May be one of the following: `req-participant`, `non-participant`
#### status([_String_ status])
Set the attendee's status. May be one of the following: `accepted`, `tentative`, `declined`
#### type([_String_ type])
Set the attendee's type. May be one of the following: `individual`, `group`, `resource`, `room`, `unknown` (See [Section 4.2.3](https://tools.ietf.org/html/rfc2445#section-4.2.3))