From de6b2362251f6de2a8a9f1acf8a73772b965384f Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Thu, 6 Feb 2014 10:48:02 -0800 Subject: [PATCH] zone setter can now skip adjusting the hour When you change the zone you'd expect the time to remain the same, but if you're doing something low-level you might want just the zone offset to change. Add a second argument to zone that would allow the caller to disable adjusting the hour when setting a zone. --- moment.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/moment.js b/moment.js index edf54c173..2f368f3d8 100644 --- a/moment.js +++ b/moment.js @@ -2038,7 +2038,8 @@ return other > this ? this : other; }, - zone : function (input) { + zone : function (input, adjust) { + adjust = (adjust == null ? true : false); var offset = this._offset || 0; if (input != null) { if (typeof input === "string") { @@ -2049,7 +2050,7 @@ } this._offset = input; this._isUTC = true; - if (offset !== input) { + if (offset !== input && adjust) { addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true); } } else { -- 2.47.2