Hello,
 
Anyone know how to get the TableSorter plugin to reliably sort short
dates?
 
By default it works with dates in a long format (US) like this:
 
April 25, 2007 12:00 Am
 
But it won't work with a short format (out of the box) like:

April 25, 2007
 
However, I did manage to get it to sort with that short date format, but
it seems to be a bit unreliable. For example, I have four rows that are
being sorted like:
 
May 1, 2007
April 15, 2007
April 16, 2007
April 27, 2007
 
Clearly this is wrong and should be:

May 1, 2007
April 27, 2007
April 16, 2007
April 15, 2007

The modification I made was simple. I added a conditional(?) grouping on
the time portion of the regex.

(watch wrap)
Original: (on or around line 510)

/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2})
(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/

Mine:

/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2})(
(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM))))?$/


It seems to work fine most of the time but on rare occasions I've seen
it act screwy.


Any ideas?



Thanks,
Chris.

Reply via email to