-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdquery.min.js
1 lines (1 loc) · 7.52 KB
/
dquery.min.js
1
(function(a){function c(g){return g.toLowerCase().replace(/^(\w)/,function(h,i){return i.toUpperCase()})}function e(h,g,i){if(typeof i=="undefined"||typeof h=="undefined"){return i}i=String(i);while(i.length<g){i=h+i}return i}function f(g){var h;if(g instanceof Date||typeof g=="number"){h=new Date(g)}else{if(typeof g=="string"){h=f.parse(g)}else{h=new Date()}}if(!h||/Invalid/.test(String(h))){throw new Error("Invalid date "+h)}return f.extend(h,f.methods)}function d(g){if(typeof g=="number"){return Math.abs(g%7)}return b.index(c(g),b.i8n.weekdays)}var b=f;f.methods={daysInMonth:function(){var g=new Date(this);g.setDate(1);g.setMonth(g.getMonth()+1);g.setDate(0);return g.getDate()},addMilliseconds:function(g){this.setTime(this.getTime()+g);return this},addSeconds:function(g){this.setSeconds(this.getSeconds()+g);return this},addMinutes:function(g){this.setMinutes(this.getMinutes()+g);return this},addHours:function(g){this.setHours(this.getHours()+g);return this},addDays:function(g){return this.addHours(g*24)},addWeeks:function(g){return this.addDays(g*7)},addMonths:function(g){return this.set("month",this.getMonth()+g)},addYears:function(g){this.addMonths(g*12);return this},resetTime:function(){return this.set({hours:0,minutes:0,seconds:0,ms:0})},resetDate:function(){return this.set("date",1).set("month",0).set("year",1970)},clone:function(){return f(this)},set:function(h,i){if(h&&i===undefined){for(var j in h){if(this.set(j,h[j])===undefined){return undefined}}return this}else{switch(h){case"date":return this.setDate(i)&&this;case"year":return this.setFullYear(i)&&this;case"month":var g=this.getDate();this.setDate(1);this.setMonth(i);this.setDate(Math.min(this.daysInMonth(),g));return this;case"seconds":return this.setSeconds(i)&&this;case"minutes":return this.setMinutes(i)&&this;case"hours":return this.setHours(i)&&this;case"ms":return this.setMilliseconds(i)&&this}return undefined}},firstDayOfYear:function(){return this.set("date",1).set("month",0)},lastDayOfYear:function(){return this.set("month",12).set("date",0)},lastDayOfMonth:function(){return this.addMonths(1).set("date",0)},firstDayOfMonth:function(){return this.set("date",1)},format:function(i){var g=this;var h=/((d+){1,4}|(m+){1,4}|yy(?:yy)?|HH?|ss?|MM?|hh?|a)/g;return i.replace(h,function(j,k){if(f.formatSpecifiers[k]){return f.formatSpecifiers[k].apply(g)}return k})},sameDate:function(g){return this.getDate()==g.getDate()&&this.getMonth()==g.getMonth()&&this.getFullYear()==g.getFullYear()},isYesterday:function(g){return this.sameDate(f(g||new Date).addDays(-1))},isTomorrow:function(g){return this.sameDate(f(g||new Date).addDays(1))},isLeapYear:function(){var g=this.getFullYear();return(g%4==0&&g%100==0&&g%400==0)||g%4==0},getWeek:function(){var j=7*24*60*60*1000;var h=f.i8n.weekstart;var k=(d(h)-1)%7;var i=f.i8n.weekdays[k];var g=(k==0)?4:1;var l=this.clone().next(i,{exceptSame:true});l.set({month:0,date:g}).prev(h,{exceptSame:true});if(this<l){l.addYears(-1).prev(h,{exceptSame:true})}return Math.floor((+this-+l)/j)+1},firstWeek:function(){return this.prev("monday",{exceptSame:true}).addWeeks(-this.getWeek()+1)},setWeek:function(g){return this.addWeeks(-this.getWeek()+g)},next:function(g,i){var h=d(g)%7;if(i&&i.exceptSame&&h==this.getDay()){return this}else{var j=7-(7+this.getDay()-h)%7;return this.addDays(j||7)}},prev:function(g,i){var h=d(g)%7;if(i&&i.exceptSame&&h==this.getDay()){return this}else{var j=(this.getDay()+7-h)%7;return this.addDays(-j||-7)}},daysOfWeek:function(){var h=new f.DateList();var j=this.clone().prev(f.i8n.weekstart,{exceptSame:true});for(var g=0;g<7;g++){h.push(j.clone());j.addDays(1)}return h},daysOfMonth:function(){var g=new f.DateList();var h=this.clone().firstDayOfMonth();f.iterate({start:h.clone(),stop:h.clone().lastDayOfMonth()},function(i){g.push(i)});return g}};f.formatSpecifiers={HH:function(){return e("0",2,this.getHours())},H:function(){return String(this.getHours())},h:function(){if(this.getHours()%12==0){return"12"}return this.getHours()%12},hh:function(){if(this.getHours()%12==0){return"12"}return e("0",2,this.getHours()%12)},M:function(){return String(this.getMinutes())},MM:function(){return e("0",2,this.getMinutes())},s:function(){return String(this.getSeconds())},ss:function(){return e("0",2,this.getSeconds())},yy:function(){return String(this.getFullYear()).substring(2,4)},yyyy:function(){return String(this.getFullYear())},m:function(){return String(this.getMonth()+1)},mm:function(){return e("0",2,this.getMonth()+1)},mmm:function(){return f.i8n.months[this.getMonth()]},mmmm:function(){return f.i8n.months[this.getMonth()+12]},dddd:function(){return f.i8n.weekdays[this.getDay()+7]},ddd:function(){return f.i8n.weekdays[this.getDay()]},dd:function(){return e("0",2,this.getDate())},d:function(){return String(this.getDate())},a:function(){return f.i8n.ampm[Math.floor(this.getHours()/12)]}};f.i8n={};f.i8n.ampm=["am","pm"];f.i8n.weekdays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];f.i8n.weekstart="monday";f.i8n.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","Mars","April","May","June","July","August","September","October","November","December"];(function(){f.each=function(j,k){if([].forEach){j.forEach(k)}else{for(var h=0,g=j.length;h<g;h++){if(k(j[h],h)===false){break}}}};f.map=function(i,j){var g=[],h=0;f.each(i,function(k){g[g.length]=j(k,h++)});return g};f.extend=function(h,g){for(var i in g){if(g.hasOwnProperty(i)){h[i]=g[i]}}return h};f.iterate=function(i,n){var m=f(i.start);var j=f(i.stop);var g="add"+c(i.metric||"days");var l=i.step||1;var k=i.filter;var h=0;while(m<=j){if(!k||k(m,h)){n(m.clone(),h)}h++;m[g](l)}};f.collect=function(h){var g=[];f.iterate(h,function(i){g[g.length]=i});return g};f.diff=function(i,m){var h=f(i),k=f(m);var o=~~((+k-+h)/1000);var j=~~(o/60);var n=~~(j/60);var p=~~(n/24);var g=~~(p/30);var l=~~(p/365);return{seconds:o,minutes:j,hours:n,days:p,months:g,years:l}};if([].indexOf){f.index=function(g,h){return h.indexOf(g)}}else{f.index=function(j,k){for(var h=0,g=k.length;h<g;h++){if(k[h]===j){return h}}return -1}}f.sprintf=function(h,g){return h.replace(/\{(\w+)\}/g,function(i,j){return String(g[j])})}}());(function(){var g=["{ddd}, {dd} {mmm} {yy} {HH}:{MM}:{ss} {tz}","{mm}/{dd}/{yy}","{mm}/{dd}/{yy} {HH}:{MM}","{mm}/{dd}/{yy} {HH}:{MM}:{ss}","{yy}","{yy}-{mm}","{yy}-{mm}-{dd}","{yy}{mm}{dd}","{yy}-{mm}-{dd} {HH}:{MM}","{yy}-{mm}-{dd} {HH}:{MM}:{ss}","{yy}-{mm}-{dd}T{HH}:{MM}:{ss}{tz}","{yy}-{mm}-{dd}T{HH}:{MM}:{ss}Z"];var j={ddd:"("+f.i8n.weekdays.join("|")+")",dd:"(\\d?\\d)",mmm:"("+f.i8n.months.join("|")+")",mm:"(\\d?\\d)",yy:"(\\d\\d\\d\\d|\\d\\d)",tz:"((w+){2,4}|\\+\\d\\d:?\\d\\d)",HH:"(\\d\\d)",MM:"(\\d\\d)",ss:"(\\d\\d)"};var i="{mm}/{dd}/{yy} {HH}:{MM}:{ss}{tz}";var h=f.map(g,function(n){var k=[""];var m=n.replace(/\{(\w+)\}/g,function(o,p){k[k.length]=p;return j[p]});var l=new RegExp("^"+m+"$");return function(u){var p;var t={dd:"1",mm:"1",yy:"1970",MM:"00",HH:"00",ss:"00",tz:""};var s;if(!(p=l.exec(u))){return undefined}for(var q=1,o=p.length;q<o;q++){var r=k[q];t[r]=p[q]}if(t.monthname){t.month=b.index(t.monthname,f.i8n.months)%12}if(t.year&&t.year.length==2){t.year="20"+t.year}if(t.timezone){t.timezone=t.timezone.replace(":","")}s=f.sprintf(i,t);return f(new Date(s))}});f.parse=function(o){var m;for(var n=0,k=h.length;n<k;n++){if(m=h[n](o)){return m}}}}());(function(){var h=f.DateList=function(){};var g=h.prototype=Array.prototype;g.each=function(i){f.each(this,i)};g.map=function(j){var i=new h;i.push.apply(i,f.map(this,j));return i}}());a.dquery=f})(typeof exports=="undefined"&&window||exports);