diff --git a/ics.js b/ics.js index 68180da..a66ecbb 100644 --- a/ics.js +++ b/ics.js @@ -111,28 +111,29 @@ var ics = function(uidDomain, prodId) { var end_date = new Date(stop); var now_date = new Date(); - var start_year = ("0000" + (start_date.getFullYear().toString())).slice(-4); - var start_month = ("00" + ((start_date.getMonth() + 1).toString())).slice(-2); - 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.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.getSeconds().toString())).slice(-2); - - var now_year = ("0000" + (now_date.getFullYear().toString())).slice(-4); - var now_month = ("00" + ((now_date.getMonth() + 1).toString())).slice(-2); - var now_day = ("00" + ((now_date.getDate()).toString())).slice(-2); - var now_hours = ("00" + (now_date.getHours().toString())).slice(-2); - var now_minutes = ("00" + (now_date.getMinutes().toString())).slice(-2); - var now_seconds = ("00" + (now_date.getSeconds().toString())).slice(-2); + var start_year = ("0000" + (start_date.getUTCFullYear().toString())).slice(-4); + var start_month = ("00" + ((start_date.getUTCMonth() + 1).toString())).slice(-2); + var start_day = ("00" + ((start_date.getUTCDate()).toString())).slice(-2); + var start_hours = ("00" + (start_date.getUTCHours().toString())).slice(-2); + var start_minutes = ("00" + (start_date.getUTCMinutes().toString())).slice(-2); + var start_seconds = ("00" + (start_date.getUTCSeconds().toString())).slice(-2); + + var end_year = ("0000" + (end_date.getUTCFullYear().toString())).slice(-4); + var end_month = ("00" + ((end_date.getUTCMonth() + 1).toString())).slice(-2); + var end_day = ("00" + ((end_date.getUTCDate()).toString())).slice(-2); + var end_hours = ("00" + (end_date.getUTCHours().toString())).slice(-2); + var end_minutes = ("00" + (end_date.getUTCMinutes().toString())).slice(-2); + var end_seconds = ("00" + (end_date.getUTCSeconds().toString())).slice(-2); + + var now_year = ("0000" + (now_date.getUTCFullYear().toString())).slice(-4); + var now_month = ("00" + ((now_date.getUTCMonth() + 1).toString())).slice(-2); + var now_day = ("00" + ((now_date.getUTCDate()).toString())).slice(-2); + var now_hours = ("00" + (now_date.getUTCHours().toString())).slice(-2); + var now_minutes = ("00" + (now_date.getUTCMinutes().toString())).slice(-2); + var now_seconds = ("00" + (now_date.getUTCSeconds().toString())).slice(-2); // 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_hours + start_minutes + start_seconds + end_hours + end_minutes + end_seconds != 0) { @@ -141,9 +142,9 @@ var ics = function(uidDomain, prodId) { } var now_time = 'T' + now_hours + now_minutes + now_seconds; - var start = start_year + start_month + start_day + start_time; - var end = end_year + end_month + end_day + end_time; - var now = now_year + now_month + now_day + now_time; + var start = start_year + start_month + start_day + start_time + 'Z'; + var end = end_year + end_month + end_day + end_time + 'Z'; + var now = now_year + now_month + now_day + now_time + 'Z'; // recurrence rrule vars var rruleString;