tablesorter/dist/js/parsers/parser-date-two-digit-year.min.js

2 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-11-27 01:40:00 +00:00
/*! Parser: two digit year - updated 11/26/2016 (v2.28.0) */
!function(a){"use strict";var b=50,c=a.tablesorter,d=(new Date).getFullYear();c.defaults.dataRange="",c.dates||(c.dates={}),c.dates.regxxxxyy=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/,c.dates.regyyxxxx=/(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/,c.formatDate=function(a,c,e,f){if(a){var g,h,i=a.replace(/\s+/g," ").replace(/[-.,]/g,"/").replace(c,e),j=new Date(i);if(j instanceof Date&&isFinite(j)){for(g=j.getFullYear(),h=f&&f.config.dateRange||b;d-g>h;)g+=100;return j.setFullYear(g)}}return a},a.tablesorter.addParser({id:"ddmmyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$2/$1/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"mmddyy",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regxxxxyy,"$1/$2/19$3",b)},type:"numeric"}),a.tablesorter.addParser({id:"yymmdd",is:function(){return!1},format:function(a,b){return c.formatDate(a,c.dates.regyyxxxx,"$2/$3/19$1",b)},type:"numeric"})}(jQuery);