Commit d0775345 authored by Sebastian's avatar Sebastian
Browse files

Merge pull request #8 from notthetup/master

Handle timezones correctly…
parents 5943b79e 67ecb410
......@@ -78,7 +78,7 @@ var a = {
// Location
_event.location = e.location || null;
// Description
_event.description = e.description || null;
......@@ -115,17 +115,18 @@ var a = {
return (i < 10 ? '0': '') + i;
}
s = d.getFullYear();
s += pad(d.getMonth() + 1);
s += pad(d.getDate());
s = d.getUTCFullYear();
s += pad(d.getUTCMonth() + 1);
s += pad(d.getUTCDate());
if(!dateonly) {
s += 'T';
s += pad(d.getHours());
s += pad(d.getMinutes());
s += pad(d.getSeconds());
s += pad(d.getUTCHours());
s += pad(d.getUTCMinutes());
s += pad(d.getUTCSeconds());
}
s += 'Z';
return s;
}
......@@ -140,7 +141,7 @@ var a = {
}
function _getUID(e) {
return _formatDate(e.start) + 'Z-' + e.uid + '@' + cal.domain;
return _formatDate(e.start) + '-' + e.uid + '@' + cal.domain;
}
// VCALENDAR and VERSION
......@@ -216,7 +217,7 @@ var a = {
if(!cal.generated) {
cal.methods.generate();
}
res.writeHead(200, {
'Content-Type': 'text/calendar',
'Content-Disposition': 'attachment; filename="calendar.ics"'
......
......@@ -3,9 +3,9 @@ VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453
DTSTART:20131004T223930
DTEND:20131004T231500
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Simple Event
END:VEVENT
END:VCALENDAR
\ No newline at end of file
......@@ -3,9 +3,9 @@ VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453
DTSTART:20131004T223930
DTEND:20131004T231500
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Sample Event
LOCATION:localhost
DESCRIPTION:Lorem ipsum dolor sit amet\, consetetur sadipscing elitr\, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat\, sed diam voluptua.\nbeep boop
......
......@@ -3,9 +3,9 @@ VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453
DTSTART;VALUE=DATE:20131004
DTEND;VALUE=DATE:20131006
DTSTAMP:20131004T233453Z
DTSTART;VALUE=DATE:20131004Z
DTEND;VALUE=DATE:20131006Z
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
URL;VALUE=URI:http://sebbo.net/
......
......@@ -115,7 +115,7 @@ describe('ical-generator', function() {
});
});
describe('addEvent()', function() {
it('should return all public methods', function() {
var generator = require(__dirname + '/../lib/ical-generator.js'),
......@@ -258,9 +258,9 @@ describe('ical-generator', function() {
cal.addEvent({
uid: '123',
start: new Date("Fr Oct 04 2013 22:39:30"),
end: new Date("Fr Oct 04 2013 23:15:00"),
stamp: new Date("Fr Oct 04 2013 23:34:53"),
start: new Date("Fr Oct 04 2013 22:39:30 UTC"),
end: new Date("Fr Oct 04 2013 23:15:00 UTC"),
stamp: new Date("Fr Oct 04 2013 23:34:53 UTC"),
summary: 'Simple Event'
});
......@@ -280,9 +280,9 @@ describe('ical-generator', function() {
cal.addEvent({
uid: '123',
start: new Date("Fr Oct 04 2013 22:39:30"),
end: new Date("Fr Oct 04 2013 23:15:00"),
stamp: new Date("Fr Oct 04 2013 23:34:53"),
start: new Date("Fr Oct 04 2013 22:39:30 UTC"),
end: new Date("Fr Oct 04 2013 23:15:00 UTC"),
stamp: new Date("Fr Oct 04 2013 23:34:53 UTC"),
summary: 'Sample Event',
location: 'localhost',
description: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.\nbeep boop'
......@@ -304,10 +304,10 @@ describe('ical-generator', function() {
cal.addEvent({
uid: '123',
start: new Date("Fr Oct 04 2013 22:39:30"),
end: new Date("Fr Oct 06 2013 23:15:00"),
start: new Date("Fr Oct 04 2013 22:39:30 UTC"),
end: new Date("Fr Oct 06 2013 23:15:00 UTC"),
allDay: true,
stamp: new Date("Fr Oct 04 2013 23:34:53"),
stamp: new Date("Fr Oct 04 2013 23:34:53 UTC"),
summary: 'Sample Event',
organizer: {
name: 'Sebastian Pekarek',
......@@ -386,4 +386,4 @@ describe('ical-generator', function() {
assert.equal(cal.length(), 0);
});
});
});
\ No newline at end of file
});
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