From: Isaac Cambron Date: Fri, 27 Sep 2013 21:37:55 +0000 (-0400) Subject: among invalid moments, prefer the first one, regardless of score X-Git-Tag: 2.3.0~7^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42602998cb9587dadffd1b684f3f87bd26110a64;p=thirdparty%2Fmoment.git among invalid moments, prefer the first one, regardless of score --- diff --git a/moment.js b/moment.js index e080bbdfb..18863fe7b 100644 --- a/moment.js +++ b/moment.js @@ -1130,7 +1130,7 @@ makeDateFromStringAndFormat(tempConfig); if (!isValid(tempConfig)) { - currentScore += 100; + continue; } // if there is any input that was not parsed add a penalty for that format diff --git a/test/moment/create.js b/test/moment/create.js index 305113678..1b82f06cf 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -329,8 +329,8 @@ exports.create = { test.equal(moment('11-02-10', ['MM.DD.YY', 'DD-MM-YY']).format('MM DD YYYY'), '02 11 2010', 'escape RegExp special characters on comparing'); - test.equal(moment('13-14-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year'); - test.equal(moment('13-14-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year'); + test.equal(moment('13-10-98', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YY', 'use two digit year'); + test.equal(moment('13-10-1998', ['DD MM YY', 'DD MM YYYY'])._f, 'DD MM YYYY', 'use four digit year'); test.equal(moment('01', ["MM", "DD"])._f, "MM", "Should use first valid format");