From: Derk-Jan Hartman Date: Sat, 2 Sep 2017 08:51:48 +0000 (+0200) Subject: TableSorter: Sort unrecognized dates as -Infinity X-Git-Tag: 1.31.0-rc.0~2231 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=b0ea484506f0d666eec1d709f2f4d4e92b9e67a1;p=lhc%2Fweb%2Fwiklou.git TableSorter: Sort unrecognized dates as -Infinity Follow-up to: I664b4cc Bug: T174814 Change-Id: I028681172be7a30e51cab42847c4fc35e9358aca --- diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 922da319cf..ecd376a693 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -1163,7 +1163,7 @@ match = s.match( ts.rgx.isoDate[ 1 ] ); } if ( !match ) { - return 0; + return -Infinity; } // Month and day for ( i = 2; i <= 4; i += 2 ) { diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js index 257699af3a..01589c3360 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js @@ -174,7 +174,8 @@ parserTest( 'Y Dates', 'date', YDates ); ISODates = [ - [ '2000', false, 946684800000, 'Plain 4-digit year' ], + [ '', false, -Infinity, 'Not a date' ], + [ '2000', false, 946684800000, 'Plain 4-digit year' ], [ '2000-01', true, 946684800000, 'Year with month' ], [ '2000-01-01', true, 946684800000, 'Year with month and day' ], [ '2000-13-01', false, 978307200000, 'Non existant month' ],