Tablesorter - parsing long date format

Tablesorter - parsing long date format

Hello, new to Jquery, so please forgive ignorance.

I've made an attempt at adapting the following date parsing function for a longer date format -

http://www.bishless.com/blog/2010/02/16/custom-date-parser-for-jquery-tablesorter/

The date I am trying to enable Tablesorter to parse and sort correctly is in this format -

Tue 29th Jun 2010 ~ 14:54:10

Currently the first hit is returning null, so the pattern matching is failing outright.
I haven’t included the time, hoping that this won’t matter for now. I’m not too sure about the match pattern, especially for the datename, ending in ‘th’ or ‘st’.

Many thanks in advice, if you can offer any suggestions.

Here is the adapted code -

$(function() {
var dayNames = {};
dayNames["Mon"] = “01″;
dayNames["Tue"] = “02″;
dayNames["Wed"] = “03″;
dayNames["Thu"] = “04″;
dayNames["Fri"] = “05″;
dayNames["Sat"] = “06″;
dayNames["Sun"] = “07″;







var dateNames = {};
dateNames["1st"] = “01″;
dateNames["2nd"] = “02″;
dateNames["3rd"] = “03″;
dateNames["4th"] = “04″;
dateNames["5th"] = “05″;
dateNames["6th"] = “06″;
dateNames["7th"] = “0″;
dateNames["8th"] = “08″;
dateNames["9th"] = “09″;
dateNames["10th"] = “10″;
dateNames["11th"] = “11″;
dateNames["12th"] = “12″;
dateNames["13th"] = “13″;
dateNames["14th"] = “14″;
dateNames["15th"] = “15″;
dateNames["16th"] = “16″;
dateNames["17th"] = “17″;
dateNames["18th"] = “18″;
dateNames["19th"] = “19″;
dateNames["20th"] = “20″;
dateNames["21st"] = “21″;
dateNames["22nd"] = “22″;
dateNames["23rd"] = “23″;
dateNames["24th"] = “24″;
dateNames["25th"] = “25″;
dateNames["26th"] = “26″;
dateNames["27th"] = “27″;
dateNames["28th"] = “28″;
dateNames["29th"] = “29″;
dateNames["30th"] = “30″;
dateNames["31st"] = “31″;






























var monthNames = {};
monthNames["Jan"] = “01″;
monthNames["Feb"] = “02″;
monthNames["Mar"] = “03″;
monthNames["Apr"] = “04″;
monthNames["May"] = “05″;
monthNames["Jun"] = “06″;
monthNames["Jul"] = “07″;
monthNames["Aug"] = “08″;
monthNames["Sep"] = “09″;
monthNames["Oct"] = “10″;
monthNames["Nov"] = “11″;
monthNames["Dec"] = “12″;











$.tablesorter.addParser({
id: ‘bishDate’,
is: function(s) {
return false;
},
format: function(s) {
var hit = s.match(/([A-Za-z]{3})\s(\d{2}[a-z]{2})\s([A-Za-z]{3})\s(\d{4})/);





var d = hit[1];
d = dayNames[d];
var D = hit[2];
D = dateNames[D];
var m = hit[3];
m = monthNames[m];
var y = hit[4];
return “” + y + m + D + d;
},
type: ‘numeric’
});









});

$(function() {
$(“table”)
.tablesorter({widthFixed: true, widgets: ['zebra'],headers: {3: {sorter: ‘bishDate’}}, sortList: [[3,0]]})
.tablesorterPager({container: $(“#pager”)});
});