tablesorter/dist/js/parsers/parser-date-range.min.js
2015-11-22 21:21:50 -06:00

5 lines
2.6 KiB
JavaScript

/*! Parser: date ranges -updated 11/22/2015 (v2.24.6) */
!function(a){"use strict";var b,c=a.tablesorter,d={mdy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,dmy:/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,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)?)?)/gi,ymdreplace:/(\d{4})[-\s](\d{1,2})[-\s](\d{1,2})/,overall_dMMMyyyy:/(\d{1,2}\s+\w+\s+\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s\w+)?)?)/g,matches_dMMMyyyy:/(\d{1,2})\s+(\w+)\s+(\d{4})/};/*! date-range MMDDYYYY */
a.tablesorter.addParser({id:"date-range-mdy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.mdy),f=c&&c.length){for(e=0;f>e;e++)b=new Date(c[e]),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */
a.tablesorter.addParser({id:"date-range-dmy",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.dmy),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.dmyreplace,"$2/$1/$3")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),/*! date-range DDMMYYYY */
a.tablesorter.addParser({id:"date-range-ymd",is:function(){return!1},format:function(a){var b,c,e,f,g=[];if(c=a.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d.ymd),f=c&&c.length){for(e=0;f>e;e++)b=new Date((""+c[e]).replace(d.ymdreplace,"$2/$3/$1")),g.push(b instanceof Date&&isFinite(b)?b.getTime():c[e]);return g.sort().join(" - ")}return a},type:"text"}),c.dates||(c.dates={}),c.dates.months||(c.dates.months={}),c.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},b=function(a,b,d){var e,f,g=b.globalize&&(b.globalize[d]||b.globalize)||{},h=c.dates.months[g.lang||"en"];b.ignoreCase&&(a=a.toLowerCase());for(f in h)if("string"==typeof f&&(e=h[f],b.ignoreCase&&(e=e.toLowerCase()),a.match(e)))return parseInt(f,10);return a},c.addParser({id:"date-range-dMMMyyyy",is:function(){return!1},format:function(a,e,f,g){var h,i,j,k,l=[],m=a.replace(/\s+/g," ").match(d.overall_dMMMyyyy),n=m&&m.length;if(n){for(k=0;n>k;k++)h="",j=m[k].match(d.matches_dMMMyyyy),j&&j.length>=4&&(j.shift(),i=b(j[1],e.config,g),isNaN(i)||(m[k]=m[k].replace(j[1],i)),h=new Date((""+m[k]).replace(c.regex.shortDateXXY,"$3/$2/$1"))),l.push(h instanceof Date&&isFinite(h)?h.getTime():m[k]);return l.sort().join(" - ")}return a},type:"text"})}(jQuery);