From: Isaac Cambron Date: Tue, 17 Sep 2013 03:13:24 +0000 (-0400) Subject: adding parseZone() X-Git-Tag: 2.3.0~30^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1106%2Fhead;p=thirdparty%2Fmoment.git adding parseZone() --- diff --git a/moment.js b/moment.js index 7c6b3359a..de2478404 100644 --- a/moment.js +++ b/moment.js @@ -1244,6 +1244,10 @@ return normalizeUnits(units); }; + moment.parseZone = function (input) { + return moment(input).parseZone(); + }; + /************************************ Moment Prototype ************************************/ @@ -1543,6 +1547,13 @@ return this._isUTC ? "Coordinated Universal Time" : ""; }, + parseZone : function () { + if (typeof this._i === 'string') { + this.zone(this._i); + } + return this; + }, + hasAlignedHourOffset : function (input) { if (!input) { input = 0; diff --git a/test/moment/zones.js b/test/moment/zones.js index 46a22dc85..3019b82bb 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -460,6 +460,22 @@ exports.zones = { test.equals(m.hasAlignedHourOffset(moment().zone(35)), false); test.equals(m.hasAlignedHourOffset(moment().zone(-85)), false); + test.done(); + }, + + "parse zone" : function (test) { + test.expect(2); + var m = moment("2013-01-01T00:00:00-13:00").parseZone(); + test.equal(m.zone(), 13 * 60); + test.equal(m.hours(), 0); + test.done(); + }, + + "parse zone static" : function (test) { + test.expect(2); + var m = moment.parseZone("2013-01-01T00:00:00-13:00"); + test.equal(m.zone(), 13 * 60); + test.equal(m.hours(), 0); test.done(); } };