From: Tim Perry Date: Wed, 11 Dec 2013 08:21:35 +0000 (+0000) Subject: Make parseZone() use the format-specified timezone if available X-Git-Tag: 2.5.0^2~6^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=531dcdc4815d3f49d2bb0d8e78ddfdfe535b22c4;p=thirdparty%2Fmoment.git Make parseZone() use the format-specified timezone if available --- diff --git a/moment.js b/moment.js index d98f06ed3..7dc8c6dc5 100644 --- a/moment.js +++ b/moment.js @@ -2017,7 +2017,9 @@ }, 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; diff --git a/test/moment/zones.js b/test/moment/zones.js index 4a7770fd9..eb638db1d 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -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");