shortDate parser now includes times in the sort

This commit is contained in:
Rob Garrison 2012-04-17 14:19:12 -05:00
parent f014e3cb6b
commit 2974c7b8d4
5 changed files with 35 additions and 15 deletions

View File

@ -35,6 +35,10 @@ tablesorter can successfully parse and sort many types of data including linked
View the [complete listing here](https://github.com/Mottie/tablesorter/wiki/Change).
#### Version 2.1.14 (4/17/2012)
* Updated "shortDate" parser to include the time, if provided. I've also updated the [Changing the date format](http://mottie.github.com/tablesorter/docs/example-option-date-format.html) demo with a few times.
#### Version 2.1.13 (4/17/2012)
* Modified "digit" parser to not remove alphabetical characters as it was breaking the [text strings in numerical sort](http://mottie.github.com/tablesorter/docs/example-options-headers-digits-strings.html) functionality.

View File

@ -46,6 +46,7 @@
<em>NOTE!</em>
<ul>
<li>The dateFormat option was modified in version 2.0.23 (not part of the original plugin).</li>
<li>The dateFormat option will ONLY work with the <code class="hilight">shortDate</code> parser.</li>
<li>The date can be separated by any of the following: slash, dash, period, comma, space(s) or tab (/-., ).</li>
<li>This date format parser will only work with a four digit year. You can <a href="example-parsers.html">write your own</a> if you need a two digit year parser.</a>
</ul>
@ -66,6 +67,11 @@
<td>7-8-2011</td>
<td>2011-8-7</td>
</tr>
<tr>
<td>11/1/2011 12:34 AM</td>
<td>1/11/2011 12:34 AM</td>
<td>2011/11/1 12:34 AM</td>
</tr>
<tr>
<td>12/28/2011</td>
<td>28/12/2011</td>
@ -77,9 +83,9 @@
<td>2011 6 30</td>
</tr>
<tr>
<td>11/1/2011</td>
<td>1/11/2011</td>
<td>2011/11/1</td>
<td>11/1/2011 12:35 AM</td>
<td>1/11/2011 12:35 AM</td>
<td>2011/11/1 12:35 AM</td>
</tr>
<tr>
<td>3.4.2011</td>
@ -87,15 +93,20 @@
<td>2011.3.4</td>
</tr>
<tr>
<td>07 01-2011</td>
<td>01 7-2011</td>
<td>2011-7 01</td>
<td>07 01-2011 1:15 PM</td>
<td>01 7-2011 1:15 PM</td>
<td>2011-7 01 1:15 PM</td>
</tr>
<tr>
<td>04/5,2011</td>
<td>5/04,2011</td>
<td>2011,04/5</td>
</tr>
<tr>
<td>11/1/2011 12:34 PM</td>
<td>1/11/2011 12:34 PM</td>
<td>2011/11/1 12:34 PM</td>
</tr>
<tr>
<td>1/21 2011</td>
<td>21.1/2011</td>
@ -106,6 +117,11 @@
<td>24.5-2011</td>
<td>2011-5.24</td>
</tr>
<tr>
<td>07/01-2011 12:15 PM</td>
<td>01-7/2011 12:15 PM</td>
<td>2011/7-01 12:15 PM</td>
</tr>
<tr>
<td>10,14,2011</td>
<td>14,10,2011</td>

View File

@ -1,5 +1,5 @@
/*!
* TableSorter 2.1.13 - Client-side table sorting with ease!
* TableSorter 2.1.14 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+
*
* Copyright (c) 2007 Christian Bach
@ -18,7 +18,7 @@
$.extend({
tablesorter: new function(){
this.version = "2.1.13";
this.version = "2.1.14";
var parsers = [], widgets = [], tbl;
this.defaults = {
@ -902,13 +902,13 @@
format: function(s, table, cell, cellIndex) {
var c = table.config,
format = (c.headers && c.headers[cellIndex]) ? c.headers[cellIndex].dateFormat || c.dateFormat : c.dateFormat; // get dateFormat from header or config
s = s.replace(/\s+/g," ").replace(/[\-|\.|\,|\s]/g, "/");
s = s.replace(/\s+/g," ").replace(/[\-|\.|\,]/g, "/");
if (format === "mmddyyyy") {
s = s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/, "$3/$1/$2");
s = s.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/, "$3/$1/$2");
} else if (format === "ddmmyyyy") {
s = s.replace(/(\d{1,2})\/(\d{1,2})\/(\d{4})/, "$3/$2/$1");
s = s.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/, "$3/$2/$1");
} else if (format === "yyyymmdd") {
s = s.replace(/(\d{4})\/(\d{1,2})\/(\d{1,2})/, "$1/$2/$3");
s = s.replace(/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/, "$1/$2/$3");
}
return $.tablesorter.formatFloat(new Date(s).getTime());
},

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "tablesorter",
"version": "2.1.13",
"version": "2.1.14",
"title": "tablesorter",
"author": {
"name": "Christian Bach",