From 279eb634db1599b33aed75ae649e63e5ac7190f0 Mon Sep 17 00:00:00 2001 From: liebeskind Date: Tue, 6 Oct 2015 17:04:10 -0400 Subject: [PATCH 1/4] Adds timezone support. --- ics.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ics.js b/ics.js index 083d963..d939147 100644 --- a/ics.js +++ b/ics.js @@ -54,8 +54,11 @@ var ics = function() { }; //TODO add time and time zone? use moment to format? - var start_date = new Date(begin); - var end_date = new Date(stop); + var offset = new Date().getTimezoneOffset(); + var tempStartDate = new Date(begin).getTime() + offset*60*1000 + var start_date = new Date(tempStartDate); + var tempEndDate = new Date(begin).getTime() + offset*60*1000 + var end_date = new Date(tempEndDate); var start_year = ("0000" + (start_date.getFullYear().toString())).slice(-4); var start_month = ("00" + ((start_date.getMonth() + 1).toString())).slice(-2); From 71313ccd3c27da1e5b9c9ce687354d7f2b225f83 Mon Sep 17 00:00:00 2001 From: liebeskind Date: Tue, 6 Oct 2015 17:04:44 -0400 Subject: [PATCH 2/4] Fixes issue where calendar time ignored and was always setting as all-day --- ics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ics.js b/ics.js index d939147..9cc667e 100644 --- a/ics.js +++ b/ics.js @@ -89,8 +89,8 @@ var ics = function() { 'BEGIN:VEVENT', 'CLASS:PUBLIC', 'DESCRIPTION:' + description, - 'DTSTART;VALUE=DATE:' + start, - 'DTEND;VALUE=DATE:' + end, + 'DTSTART;VALUE=DATE-TIME:' + start, + 'DTEND;VALUE=DATE-TIME:' + end, 'LOCATION:' + location, 'SUMMARY;LANGUAGE=en-us:' + subject, 'TRANSP:TRANSPARENT', From 1a3a0d4c05b23cb91af860feb1ef7739d6ca78cb Mon Sep 17 00:00:00 2001 From: liebeskind Date: Tue, 6 Oct 2015 17:05:32 -0400 Subject: [PATCH 3/4] Fixes typo in start_seconds & end_seconds --- ics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ics.js b/ics.js index 9cc667e..10aafa1 100644 --- a/ics.js +++ b/ics.js @@ -65,14 +65,14 @@ var ics = function() { var start_day = ("00" + ((start_date.getDate()).toString())).slice(-2); var start_hours = ("00" + (start_date.getHours().toString())).slice(-2); var start_minutes = ("00" + (start_date.getMinutes().toString())).slice(-2); - var start_seconds = ("00" + (start_date.getMinutes().toString())).slice(-2); + var start_seconds = ("00" + (start_date.getSeconds().toString())).slice(-2); var end_year = ("0000" + (end_date.getFullYear().toString())).slice(-4); var end_month = ("00" + ((end_date.getMonth() + 1).toString())).slice(-2); var end_day = ("00" + ((end_date.getDate()).toString())).slice(-2); var end_hours = ("00" + (end_date.getHours().toString())).slice(-2); var end_minutes = ("00" + (end_date.getMinutes().toString())).slice(-2); - var end_seconds = ("00" + (end_date.getMinutes().toString())).slice(-2); + var end_seconds = ("00" + (end_date.getSeconds().toString())).slice(-2); // Since some calendars don't add 0 second events, we need to remove time if there is none... var start_time = ''; From 856a63ae8cf11c90a688cd03691a735bca9e21ed Mon Sep 17 00:00:00 2001 From: liebeskind Date: Tue, 6 Oct 2015 17:06:28 -0400 Subject: [PATCH 4/4] Fixed issue where time was being ignored if didn't have minutes or seconds. --- ics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ics.js b/ics.js index 10aafa1..6590e9a 100644 --- a/ics.js +++ b/ics.js @@ -77,7 +77,7 @@ var ics = function() { // Since some calendars don't add 0 second events, we need to remove time if there is none... var start_time = ''; var end_time = ''; - if (start_minutes + start_seconds + end_minutes + end_seconds != 0) { + if (start_hours + start_minutes + start_seconds + end_hours + end_minutes + end_seconds != 0) { start_time = 'T' + start_hours + start_minutes + start_seconds; end_time = 'T' + end_hours + end_minutes + end_seconds; }