in the plugin code there's this shortdate parser,

ts.addParser({
                id: "shortDate",
                is: function(s) {
                        return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);
                },
                format: function(s,table) {
                        var c = table.config;
                        s = s.replace(/\-/g,"/");
                        if(c.dateFormat == "us") {
                                // reformat the string in ISO format
                                s = 
s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,
"$3/$1/$2");
                        } else if(c.dateFormat == "uk") {
                                //reformat the string in ISO format
                                s = 
s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,
"$3/$2/$1");
                        } else if(c.dateFormat == "dd/mm/yy" || c.dateFormat == 
"dd-mm-yy")
{
                                s = 
s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,
"$1/$2/$3");
                        }
                        return $.tablesorter.formatFloat(new Date(s).getTime());
                },
                type: "numeric"
        });


but i'm not sure it's what i need neither know how to use it...

maybe?

        $("#elencoHome").tablesorter({
                sorter: 'shortDate'
        });

but it doesn't work anyway..


On 24 Set, 14:50, hcvitto <[EMAIL PROTECTED]> wrote:
> hi
> i tried the code, no effect though..
>
> On 24 Set, 13:39, MorningZ <[EMAIL PROTECTED]> wrote:
>
> > Give this custom parser a shot
>
> > $.tablesorter.addParser({
> >                     id: 'DD-MMM-YY',
> >                     is: function(s) {
> >                         return false;
> >                     },
> >                     format: function(s) {
> >                         s = '' + s; //Make sure it's a string
> >                         var hit = s.match(/(\d{1,2})\.(\d{1,2}).
> > (\d{4})/);
> >                         if (hit && hit.length == 4) {
> >                             return hit[3] + hit[2] + hit[1];
> >                         }
> >                         else {
> >                             return s;
> >                         }
> >                     },
> >                     type: 'text'
> >                 });
>
> >                 //Wire up this custom parser to needed column
> >                 $("#myTable").tablesorter({
> >                     headers: {
> >                         6: {
> >                             sorter: 'dd.mm.yyyy
> >                         }
> >                     }
> >                 });
>
> >             });

Reply via email to