Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make parseZone() use the format-specified timezone if available
  • Loading branch information
Tim Perry authored and pimterry committed Dec 15, 2013
1 parent db05dae commit 531dcdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion moment.js
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions test/moment/zones.js
Expand Up @@ -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");
Expand Down

0 comments on commit 531dcdc

Please sign in to comment.