Last modified: 2014-02-12 23:35:36 UTC
In some rows of sortable tables stay not the full qualified date, but only the year is known. The enhanchment is, that this is detected by tablesorter. Example: {| class="wikitable sortable" ! data-sort-type="date" |"Date" |- | 1. 1. 2000 |- | 2011 |- | about 1900 |- | 2010<ref>cite</ref> |} Today (2013-01-25) only the first row is a 'date'. To prevent mistake in auto detecting parser this should work only if data-sort-type="date" is spezified. Sugestion: add folow code at row 926 in jquery.tablesorter.js: } else if ( ( match = s.match( new RegExp( /(\d{2,4})/) ) ) !== null ) { // only year s = [ match[1], '99', '99' ];
IMHO "Month Year" should be recognized, too.
There is an assortment of enhancements that could be made. 1: Add support for AD/BC 2: Add support for month/year 3: Add support for year only 4: Do something more intelligent with / - ' ' usage ? 5: Write testcases (Really this would help so much...) 6: Fix isoDate to be able to use time notation and timezones. It's not really hard to do, someone just has to do it. Biggest thing to remember is that table sorter uses 2 functions for everything. One simple function with a simple regex for auto detecting the type of a column based on the first 3 cells, and a second function with logic for calculating the actual sortkey.
Also, there is a lot of inspiration for regex'es perhaps in https://github.com/Mottie/tablesorter This is a fork of the tablesorter 2.0 version, that seems to be the most well maintained version atm. It has diverted a lot from table sorter in MW, but a lot of the regexes and test cases might still be useful for anyone who wants to dabble in it. It does require paying attention though. We have also fixed some bugs already, and we don't want to break those situations again (and that is hard to test, since we have few testcases on the regexes atm.