Commit fa2337c9 authored by Mike Pennisi's avatar Mike Pennisi
Browse files

Add support for specification of "floating" times

parent ecffb693
......@@ -98,6 +98,17 @@ cal.addEvent({
#### options.allDay (Bool)
Appointment is for the whole day
#### options.floating (Bool)
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.
#### options.stamp (Date Object)
Appointment date of creation
......
......@@ -112,6 +112,9 @@ var a = {
}
_event.stamp = e.stamp || new Date();
// Floating times
_event.floating = e.floating || false;
// Summary
if(!e.summary) {
throw 'event.summary is a mandatory item.';
......@@ -162,7 +165,7 @@ var a = {
generate: function() {
var g;
function _formatDate(d, dateonly) {
function _formatDate(d, dateonly, floating) {
var s;
function pad(i) {
......@@ -178,7 +181,10 @@ var a = {
s += pad(d.getUTCHours());
s += pad(d.getUTCMinutes());
s += pad(d.getUTCSeconds());
s += 'Z';
if(!floating) {
s += 'Z';
}
}
return s;
......@@ -228,8 +234,8 @@ var a = {
g += 'DTSTART;VALUE=DATE:' + _formatDate(e.start, true) + '\n';
g += 'DTEND;VALUE=DATE:' + _formatDate(e.end, true) + '\n';
}else{
g += 'DTSTART:' + _formatDate(e.start) + '\n';
g += 'DTEND:' + _formatDate(e.end) + '\n';
g += 'DTSTART:' + _formatDate(e.start, false, e.floating) + '\n';
g += 'DTEND:' + _formatDate(e.end, false, e.floating) + '\n';
}
if(e.repeating) {
......
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-1@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930
DTEND:20131006T231500
SUMMARY:floating
END:VEVENT
END:VCALENDAR
\ No newline at end of file
......@@ -500,6 +500,30 @@ describe('ical-generator', function() {
assert.equal(cal.toString(), fs.readFileSync(__dirname + '/results/generate_04.ics', 'utf8'));
});
it('case #5 (floating)', function() {
var fs = require('fs'),
generator = require(__dirname + '/../lib/ical-generator.js'),
cal = generator();
cal.setDomain('sebbo.net');
cal.setProdID({
company: 'sebbo.net',
product: 'ical-generator.tests'
});
cal.addEvent({
uid: '1',
start: new Date("Fr Oct 04 2013 22:39:30 UTC"),
end: new Date("Fr Oct 06 2013 23:15:00 UTC"),
stamp: new Date("Fr Oct 04 2013 23:34:53 UTC"),
summary: 'floating',
floating: true
});
fs.writeFileSync(__dirname + '/results/mike.ics', cal.toString());
assert.equal(cal.toString(), fs.readFileSync(__dirname + '/results/generate_05.ics', 'utf8'));
});
});
......
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