Comparing version 0.3.0 to 0.3.1
@@ -75,3 +75,3 @@ // Copyright (C) 2011 Tri Tech Computers Ltd. | ||
// YYYYMMDDTHHMMSS | ||
// TODO: Support UTC and TZ values | ||
// TODO: Support local time with TZID values | ||
format: function(value) { | ||
@@ -81,3 +81,6 @@ if(!(value instanceof Date)) | ||
return format_value('DATE', value)+'T'+format_value('TIME', value); | ||
return value.getUTCFullYear() | ||
+pad(value.getUTCMonth()+1) | ||
+pad(value.getUTCDate()) | ||
+'T'+format_value('TIME', value); | ||
}, | ||
@@ -174,12 +177,18 @@ parse: function(value, parameters, calendar) { | ||
// TODO: Right now we always use pure local time | ||
// That means the timezone is ignored and times are always local | ||
return pad(value.getHours()) | ||
+pad(value.getMinutes()) | ||
+pad(value.getSeconds()); | ||
return pad(value.getUTCHours()) | ||
+pad(value.getUTCMinutes()) | ||
+pad(value.getUTCSeconds()) | ||
+'Z'; | ||
}, | ||
parse: function(value) { | ||
return new Date(0,0,0, | ||
var utc = value.length > 6 ? value[6] === 'Z' : false; | ||
if(utc) | ||
return new Date(Date.UTC(0,0,0, | ||
parseInt(value.substr(0, 2), 10), | ||
parseInt(value.substr(2, 2), 10), | ||
parseInt(value.substr(4, 2), 10))); | ||
else | ||
return new Date(0,0,0, | ||
parseInt(value.substr(0, 2), 10), | ||
parseInt(value.substr(2, 2), 10), | ||
parseInt(value.substr(4, 2), 10)); | ||
@@ -186,0 +195,0 @@ } |
{ | ||
"name": "icalendar", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": "James Emerton <james@tri-tech.com>", | ||
@@ -5,0 +5,0 @@ "description": "RFC5545 iCalendar parser/generator", |
@@ -23,4 +23,4 @@ // Test search | ||
var vevent = new icalendar.VEvent('testuid@daybilling.com'); | ||
vevent.addProperty('DTSTART', new Date(2011,10,12,14,00,00)); | ||
vevent.addProperty('DTEND', new Date(2011,10,12,15,03,00)); | ||
vevent.addProperty('DTSTART', new Date(Date.UTC(2011,10,12,14,00,00))); | ||
vevent.addProperty('DTEND', new Date(Date.UTC(2011,10,12,15,03,00))); | ||
@@ -32,4 +32,4 @@ var dtstamp = icalendar.format_value('DATE-TIME',vevent.getPropertyValue('DTSTAMP')); | ||
'UID:testuid@daybilling.com', | ||
'DTSTART:20111112T140000', | ||
'DTEND:20111112T150300', | ||
'DTSTART:20111112T140000Z', | ||
'DTEND:20111112T150300Z', | ||
'END:VEVENT'], vevent.format()); | ||
@@ -41,4 +41,4 @@ }); | ||
var vevent = new icalendar.VEvent('testuid@daybilling.com'); | ||
vevent.addProperty('DTSTART', new Date(2011,10,12,14,00,00)); | ||
vevent.addProperty('DTEND', new Date(2011,10,12,15,03,00)); | ||
vevent.addProperty('DTSTART', new Date(Date.UTC(2011,10,12,14,00,00))); | ||
vevent.addProperty('DTEND', new Date(Date.UTC(2011,10,12,15,03,00))); | ||
@@ -53,4 +53,4 @@ var dtstamp = icalendar.format_value('DATE-TIME',vevent.getPropertyValue('DTSTAMP')); | ||
'UID:testuid@daybilling.com\r\n'+ | ||
'DTSTART:20111112T140000\r\n'+ | ||
'DTEND:20111112T150300\r\n'+ | ||
'DTSTART:20111112T140000Z\r\n'+ | ||
'DTEND:20111112T150300Z\r\n'+ | ||
'END:VEVENT\r\n'+ | ||
@@ -62,3 +62,3 @@ 'END:VCALENDAR\r\n', vevent.toString()); | ||
var vevent = new icalendar.VEvent('testuid@daybilling.com'); | ||
vevent.setDate(new Date(2011,11,2,16,59,00), 3600); | ||
vevent.setDate(new Date(Date.UTC(2011,11,2,16,59,00)), 3600); | ||
vevent.setDescription( | ||
@@ -74,3 +74,3 @@ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod "+ | ||
'UID:testuid@daybilling.com', | ||
'DTSTART:20111202T165900', | ||
'DTSTART:20111202T165900Z', | ||
'DURATION:PT1H', | ||
@@ -77,0 +77,0 @@ 'DESCRIPTION:Lorem ipsum dolor sit amet\\, consectetur adipisicing elit\\, sed', |
@@ -12,7 +12,8 @@ | ||
var dt = new Date(2011,10,9,17,32,16); | ||
var dt2 = new Date(2011,10,10,19,32); | ||
assert.equal('20111109', icalendar.format_value('DATE', dt)); | ||
assert.equal('173216', icalendar.format_value('TIME', dt)); | ||
assert.equal('20111109T173216', icalendar.format_value('DATE-TIME', dt)); | ||
var date_only = new Date(2011,10,9); | ||
var dt = new Date(Date.UTC(2011,10,9,17,32,16)); | ||
var dt2 = new Date(Date.UTC(2011,10,10,19,32)); | ||
assert.equal('20111109', icalendar.format_value('DATE', date_only)); | ||
assert.equal('173216Z', icalendar.format_value('TIME', dt)); | ||
assert.equal('20111109T173216Z', icalendar.format_value('DATE-TIME', dt)); | ||
@@ -33,5 +34,5 @@ assert.equal('P1W', icalendar.format_value('DURATION', 60*60*24*7)); | ||
assert.equal('20111109T173216/20111110T193200', | ||
assert.equal('20111109T173216Z/20111110T193200Z', | ||
icalendar.format_value('PERIOD', [dt, dt2])); | ||
assert.equal('20111109T173216/P5DT3H', | ||
assert.equal('20111109T173216Z/P5DT3H', | ||
icalendar.format_value('PERIOD', [dt, 60*60*24*5 + 60*60*3])); | ||
@@ -38,0 +39,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150518
1411