]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
zone setter can now skip adjusting the hour 1468/head
authorIskren Chernev <iskren.chernev@gmail.com>
Thu, 6 Feb 2014 18:48:02 +0000 (10:48 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Thu, 6 Feb 2014 18:50:21 +0000 (10:50 -0800)
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

index edf54c173bc389b3200e81b3099648ab9a217048..2f368f3d8b455f5e83f77946fa5bb54a10fa9f8c 100644 (file)
--- a/moment.js
+++ b/moment.js
             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") {
                 }
                 this._offset = input;
                 this._isUTC = true;
-                if (offset !== input) {
+                if (offset !== input && adjust) {
                     addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true);
                 }
             } else {