From f1e476373a602327a5d23d2f92c7dc30ce2891fd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 1 Feb 2011 00:18:36 -0600 Subject: Fix JS date parsing sort helper How could I ever forget the awesomeness that is the JS date constructor that takes a month value between 0-11, not 1-12. Total insanity. Signed-off-by: Dan McGee --- media/archweb.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/media/archweb.js b/media/archweb.js index 330eeff9..52e817a4 100644 --- a/media/archweb.js +++ b/media/archweb.js @@ -58,9 +58,12 @@ if (typeof $.tablesorter !== 'undefined') { var matches = this.re.exec(s); if (!matches) return 0; /* skip group 6, group 7 is optional seconds */ - if (matches[7] == undefined) matches[7] = '0'; - return $.tablesorter.formatFloat(new Date( - matches[1],matches[2],matches[3],matches[4],matches[5],matches[7]).getTime()); + if (matches[7] == undefined) matches[7] = 0; + /* The awesomeness of the JS date constructor. Month needs to be + * between 0-11, because things have to be difficult. */ + var date = new Date(matches[1], matches[2] - 1, matches[3], + matches[4], matches[5], matches[7]); + return $.tablesorter.formatFloat(date.getTime()); }, type: 'numeric' }); -- cgit v1.2.3-55-g3dc8