From 388f18cfe7ece517c43fe3c1590164adf7df6e05 Mon Sep 17 00:00:00 2001 From: korelstar Date: Thu, 10 Nov 2016 10:15:49 +0100 Subject: [PATCH] Fix occasionally defective date when using allday --- .../services/businesslayer/tasksbusinesslayer.js | 14 ++++++++++---- js/public/app.js | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/js/app/services/businesslayer/tasksbusinesslayer.js b/js/app/services/businesslayer/tasksbusinesslayer.js index 82a9789a..cbadaf93 100644 --- a/js/app/services/businesslayer/tasksbusinesslayer.js +++ b/js/app/services/businesslayer/tasksbusinesslayer.js @@ -140,6 +140,14 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ }); }; + TasksBusinessLayer.prototype.momentToICALTime = function(moment, asDate) { + if(asDate) { + return ICAL.Time.fromDateString(moment.format('YYYY-MM-DD')); + } else { + return ICAL.Time.fromDateTimeString(moment.format('YYYY-MM-DDTHH:mm:ss')); + } + }; + TasksBusinessLayer.prototype.initDueDate = function(task) { var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss"); if (!due.isValid()) { @@ -170,8 +178,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { return; } - task.due = due.format('YYYY-MM-DDTHH:mm:ss'); - task.due.isDate = allDay; + task.due = this.momentToICALTime(due, allDay); // this.checkReminderDate(task); this.doUpdate(task); }; @@ -213,8 +220,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { return; } - task.start = start.format('YYYY-MM-DDTHH:mm:ss'); - task.start.isDate = allDay; + task.start = this.momentToICALTime(start, allDay); // this.checkReminderDate(taskID); this.doUpdate(task); }; diff --git a/js/public/app.js b/js/public/app.js index 058c80b6..69ce6437 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -2169,6 +2169,14 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ }); }; + TasksBusinessLayer.prototype.momentToICALTime = function(moment, asDate) { + if(asDate) { + return ICAL.Time.fromDateString(moment.format('YYYY-MM-DD')); + } else { + return ICAL.Time.fromDateTimeString(moment.format('YYYY-MM-DDTHH:mm:ss')); + } + }; + TasksBusinessLayer.prototype.initDueDate = function(task) { var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss"); if (!due.isValid()) { @@ -2199,8 +2207,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { return; } - task.due = due.format('YYYY-MM-DDTHH:mm:ss'); - task.due.isDate = allDay; + task.due = this.momentToICALTime(due, allDay); // this.checkReminderDate(task); this.doUpdate(task); }; @@ -2242,8 +2249,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [ } else { return; } - task.start = start.format('YYYY-MM-DDTHH:mm:ss'); - task.start.isDate = allDay; + task.start = this.momentToICALTime(start, allDay); // this.checkReminderDate(taskID); this.doUpdate(task); };