]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix timezone parsing by applying the timezone offset after date creation
authorIskren Chernev <iskren.chernev@gmail.com>
Thu, 8 May 2014 08:08:04 +0000 (01:08 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Thu, 8 May 2014 08:08:04 +0000 (01:08 -0700)
moment.js

index 117d53f5f7a04a8238f7397d44cf30f4f0c64d9c..85cfa7a8df403c9d45d741eee360d5c7a5e388f1 100644 (file)
--- a/moment.js
+++ b/moment.js
@@ -36,6 +36,7 @@
             _f : null,
             _l : null,
             _strict : null,
+            _tzm : null,
             _isUTC : null,
             _offset : null,  // optional. Combine with _isUTC
             _pf : null,
             config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
         }
 
-        // add the offsets to the time to be parsed so that we can have a clean array for checking isValid
-        input[HOUR] += toInt((config._tzm || 0) / 60);
-        input[MINUTE] += toInt((config._tzm || 0) % 60);
-
         config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input);
+        // Apply timezone offset from input. The actual zone can be changed
+        // with parseZone.
+        if (config._tzm != null) {
+            config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm);
+        }
     }
 
     function dateFromObject(config) {