tablesorter/dist/js/parsers/parser-date-extract.min.js
Rob Garrison 7f082fa019 v2.28.10
2017-05-16 15:33:15 -05:00

6 lines
1.6 KiB
JavaScript

/*! Parser: Extract out date - updated 10/26/2014 (v2.18.0) */
!function(e){"use strict";var t={usLong:/[A-Z]{3,10}\.?\s+\d{1,2},?\s+(?:\d{4})(?:\s+\d{1,2}:\d{2}(?::\d{2})?(?:\s+[AP]M)?)?/i,mdy:/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,dmy:/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,dmyreplace:/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,ymd:/(\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,ymdreplace:/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/};/*! extract US Long Date */
e.tablesorter.addParser({id:"extractUSLongDate",is:function(){return!1},format:function(e){var r,a=e?e.match(t.usLong):e;return a?(r=new Date(a[0]),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract MMDDYYYY */
e.tablesorter.addParser({id:"extractMMDDYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.mdy):e;return a?(r=new Date(a[0]),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract DDMMYYYY */
e.tablesorter.addParser({id:"extractDDMMYYYY",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.dmy):e;return a?(r=new Date(a[0].replace(t.dmyreplace,"$2/$1/$3")),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"}),/*! extract YYYYMMDD */
e.tablesorter.addParser({id:"extractYYYYMMDD",is:function(){return!1},format:function(e){var r,a=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(t.ymd):e;return a?(r=new Date(a[0].replace(t.ymdreplace,"$2/$3/$1")),r instanceof Date&&isFinite(r)?r.getTime():e):e},type:"numeric"})}(jQuery);