tablesorter/dist/js/parsers/parser-date-iso8601.min.js

7 lines
793 B
JavaScript

/*! ISO-8601 date parser - 10/26/2014 (v2.18.0)
* This parser will work with dates in ISO8601 format
* 2013-02-18T18:18:44+00:00
* Written by Sean Ellingham :https://github.com/seanellingham
* See https://github.com/Mottie/tablesorter/issues/247
*/
!function(a){"use strict";var b=/^([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})))?)?)?)?$/;a.tablesorter.addParser({id:"iso8601date",is:function(a){return a?a.match(b):!1},format:function(a){var c=a?a.match(b):a;if(c){var d=new Date(c[1],0,1);return c[3]&&d.setMonth(c[3]-1),c[5]&&d.setDate(c[5]),c[7]&&d.setHours(c[7]),c[8]&&d.setMinutes(c[8]),c[10]&&d.setSeconds(c[10]),c[12]&&d.setMilliseconds(1e3*Number("0."+c[12])),d.getTime()}return a},type:"numeric"})}(jQuery);