]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
parseZone passes all arguments to moment 1447/head
authorIskren Chernev <iskren.chernev@gmail.com>
Tue, 28 Jan 2014 09:30:20 +0000 (01:30 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Tue, 28 Jan 2014 09:30:20 +0000 (01:30 -0800)
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
test/moment/zones.js

index b79da7f26046089dd79458076a9629a7b34d2560..5c3a39da56b06e3ba32909afe5160b706bdf8954 100644 (file)
--- a/moment.js
+++ b/moment.js
         return m;
     };
 
-    moment.parseZone = function (input) {
-        return moment(input).parseZone();
+    moment.parseZone = function () {
+        return moment.apply(null, arguments).parseZone();
     };
 
     /************************************
index a497f9d6d3fb44d40f7819617d92d18eacdd1148..cd203f6321e2576cf363f97752c8c8d9bf9ef157 100644 (file)
@@ -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();
     },