(js) Fix all-day dates covering a timezone change

pull/101/head^2
Francis Lachapelle 2015-11-05 11:53:44 -05:00
parent a8525658b3
commit c5cac316c3
1 changed files with 11 additions and 2 deletions

View File

@ -213,9 +213,18 @@ Date.prototype.stringWithSeparator = function(separator) {
};
Date.prototype.addDays = function(nbrDays) {
var milliSeconds = this.getTime();
milliSeconds += 86400000 * nbrDays;
var initialDate, milliSeconds, dstOffset;
milliSeconds = this.getTime();
initialDate = new Date(milliSeconds);
milliSeconds += 86400000 * nbrDays;
this.setTime(milliSeconds);
dstOffset = this.getTimezoneOffset() - initialDate.getTimezoneOffset();
if (dstOffset !== 0) {
milliSeconds = this.getTime() + dstOffset*60*1000;
this.setTime(milliSeconds);
}
};
Date.prototype.addHours = function(nbrHours) {