On Monday, March 19, 2007 4:03 PM Remy Sharp <> said:

> If I were you I would write another analyser - to match your date
> format, then manually add 00:00:00 before converting the time to a
> numerical.  Use the existing date analyser as the template.
> 
> Hope that points you in the right direction!

Done!

A simple modification to the 'usLongDate' thingy (analyser?) does the
trick.

I'm not totally sure how to describe the change necessary but here goes:

In the definition that begins:

        $.tableSorter.parsers.usLongDate = {

look for the line that reads:

        return s.match(new RegExp(/^[A-Za-z]...

There is a clause(terminology?) at the end of the RegExp that handles
the time of day (hh:mm AM/PM) that should be enclosed in another
conditional clause to handle cases where it is not available.

(watch for line breaks)
Here's the old RegExp:
/^[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)))$/

And here's the new RegExp:
/^[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))))?$/


In case you're reading this on the web and don't know context, with the
change above you can sort 'Jan 01, 2001' just like you can 'Jan 01, 2001
00:00 AM'.


Chris.

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to