(js) Fix all-day dates covering a timezone change
This commit is contained in:
parent
a8525658b3
commit
c5cac316c3
|
@ -213,9 +213,18 @@ Date.prototype.stringWithSeparator = function(separator) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.prototype.addDays = function(nbrDays) {
|
Date.prototype.addDays = function(nbrDays) {
|
||||||
var milliSeconds = this.getTime();
|
var initialDate, milliSeconds, dstOffset;
|
||||||
milliSeconds += 86400000 * nbrDays;
|
|
||||||
|
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);
|
this.setTime(milliSeconds);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.prototype.addHours = function(nbrHours) {
|
Date.prototype.addHours = function(nbrHours) {
|
||||||
|
|
Loading…
Reference in a new issue