mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-09 08:53:20 +00:00
(js) Fix all-day dates covering a timezone change
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user