Fix all-day events covering a timezone change

This commit is contained in:
Francis Lachapelle
2015-11-03 15:47:30 -05:00
parent e5c71a4179
commit cbf9b6da3e
5 changed files with 53 additions and 39 deletions
@@ -422,13 +422,10 @@
if (this.endDate) {
this.end = new Date(this.endDate.substring(0,10) + ' ' + this.endDate.substring(11,16));
this.delta = Math.floor((Math.abs(this.end - this.start)/1000)/60);
this.delta = this.start.minutesTo(this.end);
}
else if (this.type == 'appointment') {
this.end = new Date(this.start.getTime());
this.end.setMinutes(Math.round(this.end.getMinutes()/15)*15);
this.end.addMinutes(this.delta);
//this.end.addMinutes(this.delta);
this.setDelta(this.delta);
}
if (this.dueDate)
@@ -650,6 +647,19 @@
}
};
/**
* @function setDelta
* @memberof Component.prototype
* @desc Set the end time to the specified number of minutes after the start time.
* @param {number} delta - the number of minutes
*/
Component.prototype.setDelta = function(delta) {
this.delta = delta;
this.end = new Date(this.start.getTime());
this.end.setMinutes(Math.round(this.end.getMinutes()/15)*15);
this.end.addMinutes(this.delta);
};
/**
* @function updateFreeBusy
* @memberof Component.prototype
@@ -299,11 +299,11 @@
function adjustEndTime() {
// The end date must be after the start date
var delta = vm.component.end.valueOf() - vm.component.start.valueOf();
var delta = vm.component.start.minutesTo(vm.component.end);
if (delta < 0)
vm.component.end = new Date(oldEndDate.getTime());
else {
vm.component.delta = Math.floor((Math.abs(vm.component.end - vm.component.start)/1000)/60);
vm.component.delta = delta;
oldEndDate = new Date(vm.component.end.getTime());
}
}