Page MenuHomePhabricator

jquery.tablesorter: data-sort-type="isoDate" does not work for dates in the format YYYY-MM-DDTHH:MM:SSZ
Closed, ResolvedPublic

Description

As you can check in the URL above, the current version[1] of the table sorter parser for "isoDate" doesn't work if the date has the format YYYY-MM-DDTHH:MM:SSZ. In the broken example above, clicking in the "Date" header doesn't change the order of the rows, while in the working example it does.

The code is using the regex /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/ to detect these dates (see #L620), and this doesn't take the time into account.

Moreover, in the parser (#L1011), there is a replacement of the form
"2000-01-01T00:00:00Z" --> "2000/01/01T00:00:00Z"
which will result in an invalid date when this value is passed to "new Date()"

[1] https://github.com/wikimedia/mediawiki-core/blob/5b17571e6917fb819d8d8a191df90dd88d468e09/resources/jquery/jquery.tablesorter.js


Version: 1.22.0
Severity: normal
URL: https://pt.wikipedia.org/w/index.php?oldid=36666729&uselang=en&debug=1

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:45 AM
bzimport set Reference to bz52842.
bzimport added a subscriber: Unknown Object (MLST).

Change 117808 had a related patch set uploaded by TheDJ:
TableSorter: Improve detection and handling of isoDate

https://gerrit.wikimedia.org/r/117808

Change 117808 had a related patch set uploaded (by Krinkle):
jquery.tablesorter: Improve detection and handling of isoDate

https://gerrit.wikimedia.org/r/117808

Patch-For-Review

Change 117808 merged by jenkins-bot:
jquery.tablesorter: Improve detection and handling of isoDate

https://gerrit.wikimedia.org/r/117808

matmarex assigned this task to TheDJ.
matmarex removed a project: Patch-For-Review.
matmarex set Security to None.
matmarex removed a subscriber: wikibugs-l-list.