Created
July 29, 2012 20:44
-
-
Save vivaserver/3201752 to your computer and use it in GitHub Desktop.
DDMMYY date parser for TableSorter jQuery plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DDMMYY date parser for TableSorter plugin | |
// 'cause stock "shortDate" sorter only works with 'yyyy' year format | |
// ref: http://tablesorter.com/docs/example-parsers.html | |
var regx = /(\d{2})\/(\d{2})\/(\d{2})/; | |
var match_dd_mm_yy; | |
$.tablesorter.addParser({ | |
id: "ddmmyy", | |
is: function(s) { | |
return false; | |
}, | |
format: function(s) { | |
match_dd_mm_yy = regx.exec(s); | |
// consider XX or XI century dates | |
return (match_dd_mm_yy[3]>="90" ? "19" : "20") + match_dd_mm_yy[3] + match_dd_mm_yy[2] + match_dd_mm_yy[1]; | |
}, | |
type: "numeric" | |
}); | |
$(".domains").tablesorter({ | |
headers: { | |
1: { sorter: "ddmmyy" }, | |
2: { sorter: "ddmmyy" } | |
}, | |
sortList: [[3,0]] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment