From a970ee6b9e14d7d659e3ad851a8f09037f593647 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Thu, 4 Sep 2014 23:41:41 -0700 Subject: [PATCH] Implement https://github.com/moment/moment/pull/1871#issuecomment-53700377 --- moment.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/moment.js b/moment.js index bf2dab47e..22d68b61a 100644 --- a/moment.js +++ b/moment.js @@ -2136,7 +2136,7 @@ this._isUTC = false; if (keepLocalTime) { - this.add(Math.round(this._d.getTimezoneOffset()), 'm'); + this.add(this._dateTzOffset(), 'm'); } } return this; @@ -2345,7 +2345,7 @@ input = input * 60; } if (!this._isUTC && keepLocalTime) { - localAdjust = Math.round(this._d.getTimezoneOffset()); + localAdjust = this._dateTzOffset(); } this._offset = input; this._isUTC = true; @@ -2363,7 +2363,7 @@ } } } else { - return this._isUTC ? offset : Math.round(this._d.getTimezoneOffset()); + return this._isUTC ? offset : this._dateTzOffset(); } return this; }, @@ -2493,6 +2493,12 @@ localeData : function () { return this._locale; + }, + + _dateTzOffset : function () { + // On Firefox.24 Date#getTimezoneOffset returns a floating point. + // https://github.com/moment/moment/pull/1871 + return Math.round(this._d.getTimezoneOffset() / 15) * 15; } }); -- 2.47.2