Merge pull request #10 from nextcloud/fix-allday

Fix occasionally defective date when using allday
This commit is contained in:
raimund-schluessler 2016-11-13 15:13:02 +01:00 committed by GitHub
commit 92bc2250a7
2 changed files with 20 additions and 8 deletions

View file

@ -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) { TasksBusinessLayer.prototype.initDueDate = function(task) {
var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss"); var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss");
if (!due.isValid()) { if (!due.isValid()) {
@ -170,8 +178,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
} else { } else {
return; return;
} }
task.due = due.format('YYYY-MM-DDTHH:mm:ss'); task.due = this.momentToICALTime(due, allDay);
task.due.isDate = allDay;
// this.checkReminderDate(task); // this.checkReminderDate(task);
this.doUpdate(task); this.doUpdate(task);
}; };
@ -213,8 +220,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
} else { } else {
return; return;
} }
task.start = start.format('YYYY-MM-DDTHH:mm:ss'); task.start = this.momentToICALTime(start, allDay);
task.start.isDate = allDay;
// this.checkReminderDate(taskID); // this.checkReminderDate(taskID);
this.doUpdate(task); this.doUpdate(task);
}; };

View file

@ -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) { TasksBusinessLayer.prototype.initDueDate = function(task) {
var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss"); var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss");
if (!due.isValid()) { if (!due.isValid()) {
@ -2199,8 +2207,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
} else { } else {
return; return;
} }
task.due = due.format('YYYY-MM-DDTHH:mm:ss'); task.due = this.momentToICALTime(due, allDay);
task.due.isDate = allDay;
// this.checkReminderDate(task); // this.checkReminderDate(task);
this.doUpdate(task); this.doUpdate(task);
}; };
@ -2242,8 +2249,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
} else { } else {
return; return;
} }
task.start = start.format('YYYY-MM-DDTHH:mm:ss'); task.start = this.momentToICALTime(start, allDay);
task.start.isDate = allDay;
// this.checkReminderDate(taskID); // this.checkReminderDate(taskID);
this.doUpdate(task); this.doUpdate(task);
}; };