Skip to content

Instantly share code, notes, and snippets.

@anroots
Created May 7, 2012 08:54
Show Gist options
  • Save anroots/2626766 to your computer and use it in GitHub Desktop.
Save anroots/2626766 to your computer and use it in GitHub Desktop.
Custom Tablesorter parser for Estonian date formats (dd.mm.YYYY)
// Custom date format parser for Estonian for the Tablesorter(.com) jQuery plugin
$.tablesorter.addParser({
id:'estDate',
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, '/');
s = s.replace(/(\d{1,2})\.(\d{1,2})\.(\d{4})/, '$3/$2/$1');
return $.tablesorter.formatFloat(new Date(s).getTime());
},
type:'numeric'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment