tristen/tablesort — pull request #30 by colinodell (2013-11-08 21:43:20+00:00)
Title: Check for dates by attempting to parse them

The original `testDate()` method tends to accept "false-positives". In addition to seeing if the value contains date-like elements, we should also try parsing it with `parseDate()` and ensure the result is valid.

This makes it possible for a single column to sort against multiple values. For example, say we have a table like this:

| Name | Birthday |
| ---- | -------- |
| John | 1980-10-12 |
| Sam | 1980-05-26 |
| Amy | 1980-05-26 |

When users share the same birthday, I'd like the data to be sorted by name as well. This can be accomplished by concatenating the two values in `data-sort` like so: `1980-05-26Sam` Because this is not a valid date, I would expect it to compare it as a string, but this doesn't happen. The RegEx sees the `1980-05-26` and returns true. This completely breaks sorting on that column.

This change will actually attempt parsing the date-like value to ensure it is a date. If it's not a date then `parseDate()` will return `NaN`, so we check for that.

Yes, what I'm trying to accomplish is a bit of a hack. Yes, I know multi-column sorting isn't supported. And yes, I realize I could use a UNIX timestamp to circumvent this issue. However, I still feel date detection should work properly regardless of what I throw at it.