Commit f36e3471 authored by Sebastian's avatar Sebastian
Browse files

ICalCalendar.ttl()

parent 2b2deeb8
......@@ -14,7 +14,8 @@ var ICalCalendar = function(_data) {
generate = function(calendar) {
var g = '';
var tools = require('./_tools.js'),
g = '';
// VCALENDAR and VERSION
g = 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\n';
......@@ -27,10 +28,17 @@ var ICalCalendar = function(_data) {
g += 'X-WR-CALNAME:' + data.name + '\r\n';
}
// Timezone
if(data.timezone) {
g += 'X-WR-TIMEZONE:' + data.timezone + '\r\n';
}
// TTL
if(data.ttl) {
g += 'REFRESH-INTERVAL;VALUE=DURATION:' + tools.duration(data.ttl) + '\r\n';
g += 'X-PUBLISHED-TTL:' + tools.duration(data.ttl) + '\r\n';
}
// Events
data.events.forEach(function(event) {
g += event.generate(calendar);
......@@ -216,6 +224,24 @@ var ICalCalendar = function(_data) {
};
/**
* Set/Get your feed's TTL.
* Used to set `X-PUBLISHED-TTL` and `REFRESH-INTERVAL`.
*
* @param [ttl] TTL
* @example cal.ttl(60 * 60 * 24); // 1 day
* @since 0.2.5
* @returns {ICalCalendar}
*/
this.ttl = function(ttl) {
if(!ttl) {
return data.ttl;
}
data.ttl = parseInt(ttl, 10) || null;
};
/**
* Create a new Event and return the calendar object…
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment