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

6 lines
2.6 KiB
JavaScript

/*! Parser: date ranges -updated 11/22/2015 (v2.24.6) */
!function(e){"use strict";var t,r=e.tablesorter,a={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 */
e.tablesorter.addParser({id:"date-range-mdy",is:function(){return!1},format:function(e){var t,r,n,s,d=[];if(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(a.mdy),s=r&&r.length){for(n=0;n<s;n++)t=new Date(r[n]),d.push(t instanceof Date&&isFinite(t)?t.getTime():r[n]);return d.sort().join(" - ")}return e},type:"text"}),/*! date-range DDMMYYYY */
e.tablesorter.addParser({id:"date-range-dmy",is:function(){return!1},format:function(e){var t,r,n,s,d=[];if(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(a.dmy),s=r&&r.length){for(n=0;n<s;n++)t=new Date((""+r[n]).replace(a.dmyreplace,"$2/$1/$3")),d.push(t instanceof Date&&isFinite(t)?t.getTime():r[n]);return d.sort().join(" - ")}return e},type:"text"}),/*! date-range DDMMYYYY */
e.tablesorter.addParser({id:"date-range-ymd",is:function(){return!1},format:function(e){var t,r,n,s,d=[];if(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(a.ymd),s=r&&r.length){for(n=0;n<s;n++)t=new Date((""+r[n]).replace(a.ymdreplace,"$2/$3/$1")),d.push(t instanceof Date&&isFinite(t)?t.getTime():r[n]);return d.sort().join(" - ")}return e},type:"text"}),r.dates||(r.dates={}),r.dates.months||(r.dates.months={}),r.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"},t=function(e,t,a){var n,s,d=t.globalize&&(t.globalize[a]||t.globalize)||{},i=r.dates.months[d.lang||"en"];t.ignoreCase&&(e=e.toLowerCase());for(s in i)if("string"==typeof s&&(n=i[s],t.ignoreCase&&(n=n.toLowerCase()),e.match(n)))return parseInt(s,10);return e},/*! date-range "dd MMM yyyy - dd MMM yyyy" */
r.addParser({id:"date-range-dMMMyyyy",is:function(){return!1},format:function(e,n,s,d){var i,o,c,y,l=[],g=e.replace(/\s+/g," ").match(a.overall_dMMMyyyy),m=g&&g.length;if(m){for(y=0;y<m;y++)i="",(c=g[y].match(a.matches_dMMMyyyy))&&c.length>=4&&(c.shift(),o=t(c[1],n.config,d),isNaN(o)||(g[y]=g[y].replace(c[1],o)),i=new Date((""+g[y]).replace(r.regex.shortDateXXY,"$3/$2/$1"))),l.push(i instanceof Date&&isFinite(i)?i.getTime():g[y]);return l.sort().join(" - ")}return e},type:"text"})}(jQuery);