From 969c12fa8d751f37dce5c358c3e01173175beeb7 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Tue, 28 Jan 2014 01:30:20 -0800 Subject: [PATCH] parseZone passes all arguments to moment moment.parseZone is just a shorthand for moment().parseZone(), so make sure that all arguments passed to the static function end up in the moment factory function. --- moment.js | 4 ++-- test/moment/zones.js | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/moment.js b/moment.js index b79da7f26..5c3a39da5 100644 --- a/moment.js +++ b/moment.js @@ -1755,8 +1755,8 @@ return m; }; - moment.parseZone = function (input) { - return moment(input).parseZone(); + moment.parseZone = function () { + return moment.apply(null, arguments).parseZone(); }; /************************************ diff --git a/test/moment/zones.js b/test/moment/zones.js index a497f9d6d..cd203f632 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -481,12 +481,26 @@ exports.zones = { test.equal(m.hours(), 0); test.done(); }, - + + "parse zone with more arguments" : function (test) { + var m; + test.expect(3); + + m = moment.parseZone("2013 01 01 05 -13:00", "YYYY MM DD HH ZZ"); + test.equal(m.format(), "2013-01-01T05:00:00-13:00", "accept input and format"); + m = moment.parseZone("2013-01-01-13:00", "YYYY MM DD ZZ", true); + test.equal(m.isValid(), false, "accept input, format and strict flag"); + m = moment.parseZone("2013-01-01-13:00", ["DD MM YYYY ZZ", "YYYY MM DD ZZ"]); + test.equal(m.format(), "2013-01-01T00:00:00-13:00", "accept input and array of formats"); + + test.done(); + }, + "parse zone with a timezone from the 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(); }, -- 2.47.2