]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
merging develop
authorIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 22:33:35 +0000 (18:33 -0400)
committerIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 22:33:35 +0000 (18:33 -0400)
1  2 
moment.js
test/lang/ka.js
test/moment/lang.js

diff --cc moment.js
index 91865c193dc2e15a19f4b670ecea67460193457d,af9c7aeb29db4eb8bc98960c0a401bfe1e48032d..ff1df1d55c74fe55456397afe85d3e3021f9f178
+++ b/moment.js
              } else {
                  duration.milliseconds = input;
              }
-         } else if (matched) {
-             sign = (matched[1] === "-") ? -1 : 1;
+         } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) {
+             sign = (match[1] === "-") ? -1 : 1;
              duration = {
                  y: 0,
-                 d: toInt(matched[DATE]) * sign,
-                 h: toInt(matched[HOUR]) * sign,
-                 m: toInt(matched[MINUTE]) * sign,
-                 s: toInt(matched[SECOND]) * sign,
-                 ms: toInt(matched[MILLISECOND]) * sign
 -                d: toInt(match[2]) * sign,
 -                h: toInt(match[3]) * sign,
 -                m: toInt(match[4]) * sign,
 -                s: toInt(match[5]) * sign,
 -                ms: toInt(match[6]) * sign
++                d: toInt(match[DATE]) * sign,
++                h: toInt(match[HOUR]) * sign,
++                m: toInt(match[MINUTE]) * sign,
++                s: toInt(match[SECOND]) * sign,
++                ms: toInt(match[MILLISECOND]) * sign
+             };
+         } else if (!!(match = isoDurationRegex.exec(input))) {
+             sign = (match[1] === "-") ? -1 : 1;
+             parseIso = function (inp) {
+                 // We'd normally use ~~inp for this, but unfortunately it also
+                 // converts floats to ints.
+                 // inp may be undefined, so careful calling replace on it.
+                 var res = inp && parseFloat(inp.replace(',', '.'));
+                 // apply sign while we're at it
+                 return (isNaN(res) ? 0 : res) * sign;
+             };
+             duration = {
+                 y: parseIso(match[2]),
+                 M: parseIso(match[3]),
+                 d: parseIso(match[4]),
+                 h: parseIso(match[5]),
+                 m: parseIso(match[6]),
+                 s: parseIso(match[7]),
+                 w: parseIso(match[8]),
              };
          }
  
diff --cc test/lang/ka.js
Simple merge
index 05cfca5106f188cb691ab5c9e19cc8a10405681c,a62c880b01018648e77dd21d33e730b91f62a941..0112669868b1d97e8f9be32723b44ba9f5803cd2
@@@ -240,14 -240,13 +240,24 @@@ exports.lang = 
          test.done();
      },
  
 +    "invalid date formatting" : function (test) {
 +        moment.lang('has-invalid', {
 +            invalidDate: 'KHAAAAAAAAAAAN!'
 +        });
 +
 +        test.equal(moment.invalid().format(), "KHAAAAAAAAAAAN!");
 +        test.equal(moment.invalid().format('YYYY-MM-DD'), "KHAAAAAAAAAAAN!");
 +
++        test.done();
++    },
++
+     "return lang name" : function (test) {
+         test.expect(1);
+         var registered = moment.lang('return-this', {});
+         test.equal(registered, 'return-this', 'returns the language configured');
          test.done();
      }
  };