| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
;(function($) { |
| 9 |
'use strict'; |
| 10 |
|
| 11 |
var iso8601date = /^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/; |
| 12 |
|
| 13 |
$.tablesorter.addParser({ |
| 14 |
id : 'iso8601date', |
| 15 |
is : function(s) { |
| 16 |
return s ? s.match(iso8601date) : false; |
| 17 |
}, |
| 18 |
format : function(s) { |
| 19 |
var result = s ? s.match(iso8601date) : s; |
| 20 |
if (result) { |
| 21 |
var date = new Date(result[1], 0, 1); |
| 22 |
if (result[3]) { date.setMonth(result[3] - 1); } |
| 23 |
if (result[5]) { date.setDate(result[5]); } |
| 24 |
if (result[7]) { date.setHours(result[7]); } |
| 25 |
if (result[8]) { date.setMinutes(result[8]); } |
| 26 |
if (result[10]) { date.setSeconds(result[10]); } |
| 27 |
if (result[12]) { date.setMilliseconds(Number('0.' + result[12]) * 1000); } |
| 28 |
return date.getTime(); |
| 29 |
} |
| 30 |
return s; |
| 31 |
}, |
| 32 |
type : 'numeric' |
| 33 |
}); |
| 34 |
|
| 35 |
})(jQuery); |