Last modified: 2014-02-12 23:35:36 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T46818, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44818 - jquery.tablesorter should sort plain year digits as date
jquery.tablesorter should sort plain year digits as date
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.21.x
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 31601
  Show dependency treegraph
 
Reported: 2013-02-09 18:37 UTC by Matthias
Modified: 2014-02-12 23:35 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Matthias 2013-02-09 18:37:16 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' ];
Comment 1 Michael M. 2013-12-03 10:09:07 UTC
IMHO "Month Year" should be recognized, too.
Comment 2 Derk-Jan Hartman 2013-12-03 12:49:34 UTC
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.
Comment 3 Derk-Jan Hartman 2013-12-03 12:59:44 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links