Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ics.js #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions ics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down