datetimepicker/build/jquery.datetimepicker.full.min.js

1 line
60 KiB
JavaScript
Raw Normal View History

2020-10-12 09:55:34 +00:00
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports?module.exports=t():e.DateFormatter=t()}("undefined"!=typeof self?self:this,function(){var g={DAY:864e5,HOUR:3600,defaults:{dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"],ordinal:function(e){var t=e%10,a={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(e%100/10)&&a[t]?a[t]:"th"}},separators:/[ \-+\/.:@]/g,validParts:/[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,intParts:/[djwNzmnyYhHgGis]/g,tzParts:/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,tzClip:/[^-+\dA-Z]/g},getInt:function(e,t){return parseInt(e,t||10)},compare:function(e,t){return"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase()},lpad:function(e,t,a){e=e.toString();return a=a||"0",e.length<t?g.lpad(a+e,t):e},merge:function(e){var t,a;for(e=e||{},t=1;t<arguments.length;t++)if(a=arguments[t])for(var n in a)a.hasOwnProperty(n)&&("object"==typeof a[n]?g.merge(e[n],a[n]):e[n]=a[n]);return e},getIndex:function(e,t){for(var a=0;a<t.length;a++)if(t[a].toLowerCase()===e.toLowerCase())return a;return-1}},e=function(e){var t=this,e=g.merge(g.defaults,e);t.dateSettings=e.dateSettings,t.separators=e.separators,t.validParts=e.validParts,t.intParts=e.intParts,t.tzParts=e.tzParts,t.tzClip=e.tzClip};return e.prototype={constructor:e,getMonth:function(e){var t=g.getIndex(e,this.dateSettings.monthsShort)+1;return 0===t&&(t=g.getIndex(e,this.dateSettings.months)+1),t},parseDate:function(e,t){var a,n,r,o,i,s,d,u=this,l=!1,f=!1,c=u.dateSettings,m={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(!e)return null;if(e instanceof Date)return e;if("U"===t)return(r=g.getInt(e))?new Date(1e3*r):e;switch(typeof e){case"number":return new Date(e);case"string":break;default:return null}if(!(a=t.match(u.validParts))||0===a.length)throw new Error("Invalid date format definition.");for(r=a.length-1;0<=r;r--)"S"===a[r]&&a.splice(r,1);for(n=e.replace(u.separators,"\0").split("\0"),r=0;r<n.length;r++)switch(i=n[r],o=g.getInt(i),a[r]){case"y":case"Y":if(!o)return null;s=i.length,m.year=2===s?g.getInt((o<70?"20":"19")+i):o,l=!0;break;case"m":case"n":case"M":case"F":if(isNaN(o)){if(!(0<(d=u.getMonth(i))))return null;m.month=d}else{if(!(1<=o&&o<=12))return null;m.month=o}l=!0;break;case"d":case"j":if(!(1<=o&&o<=31))return null;m.day=o,l=!0;break;case"g":case"h":if(d=n[i=-1<a.indexOf("a")?a.indexOf("a"):-1<a.indexOf("A")?a.indexOf("A"):-1],-1!==i)d=g.compare(d,c.meridiem[0])?0:g.compare(d,c.meridiem[1])?12:-1,1<=o&&o<=12&&-1!=d?m.hour=o%12==0?d:o+d:0<=o&&o<=23&&(m.hour=o);else{if(!(0<=o&&o<=23))return null;m.hour=o}f=!0;break;case"G":case"H":if(!(0<=o&&o<=23))return null;m.hour=o,f=!0;break;case"i":if(!(0<=o&&o<=59))return null;m.min=o,f=!0;break;case"s":if(!(0<=o&&o<=59))return null;m.sec=o,f=!0}if(!0===l){var h=m.year||0,t=m.month?m.month-1:0,e=m.day||1;m.date=new Date(h,t,e,m.hour,m.min,m.sec,0)}else{if(!0!==f)return null;m.date=new Date(0,0,0,m.hour,m.min,m.sec,0)}return m.date},guessDate:function(e,t){if("string"!=typeof e)return e;var a,n,r,o,i,s=e.replace(this.separators,"\0").split("\0"),d=t.match(this.validParts),u=new Date,l=0;if(!/^[djmn]/g.test(d[0]))return e;for(r=0;r<s.length;r++){if(l=2,o=s[r],i=g.getInt(o.substr(0,2)),isNaN(i))return null;switch(r){case 0:"m"===d[0]||"n"===d[0]?u.setMonth(i-1):u.setDate(i);break;case 1:"m"===d[0]||"n"===d[0]?u.setDate(i):u.setMonth(i-1);break;case 2:if(n=u.getFullYear(),l=(a=o.length)<4?a:4,!(n=g.getInt(a<4?n.toString().substr(0,4-a)+o:o.substr(0,4))))return null;u.setFullYear(n);break;case 3:u.setHours(i);break;case 4:u.setMinutes(i);break;case 5:u.setSeconds(i)}0<(o=o.substr(l)).length&&s.splice(r+1,0,o)}return u