]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Make parseZone() use the format-specified timezone if available
authorTim Perry <tim.perry@softwire.com>
Wed, 11 Dec 2013 08:21:35 +0000 (08:21 +0000)
committerpimterry <pimterry@gmail.com>
Sun, 15 Dec 2013 16:57:14 +0000 (16:57 +0000)
moment.js
test/moment/zones.js

index d98f06ed3300163489fec9868490a4eade671785..7dc8c6dc5028ab6a73cbac92d4fe83687eafb6e8 100644 (file)
--- a/moment.js
+++ b/moment.js
         },
 
         parseZone : function () {
-            if (typeof this._i === 'string') {
+            if (this._tzm) {
+                this.zone(this._tzm);
+            } else if (typeof this._i === 'string') {
                 this.zone(this._i);
             }
             return this;
index 4a7770fd9f6418c2c3d070568776c3e1341623ba..eb638db1d51aecd4c79ba7908e877537341fa258 100644 (file)
@@ -481,6 +481,15 @@ exports.zones = {
         test.equal(m.hours(), 0);
         test.done();
     },
+    
+    "parse zone dependent on format string" : function (test) {
+        test.expect(1);
+        
+        var m = moment("11-12-2013 -0400 +1100", "DD-MM-YYYY ZZ #####").parseZone();
+        
+        test.equal(m.zone(), 4 * 60);
+        test.done();
+    },
 
     "timezone format" : function (test) {
         test.equal(moment().zone(-60).format('ZZ'), "+0100", "-60 -> +0100");