!function(){var a={IS_SAME_DAY:0,FORMAT_YMD:"yyyy-MM-dd",FORMAT_YMD_HMS:"yyyy-MM-dd hh:mm:ss",ONE_DAY_TIME:864e5,format:function(a,b){var c,d;a=this.parse(a),c={"M+":a.getMonth()+1,"d+":a.getDate(),"h+":a.getHours(),"m+":a.getMinutes(),"s+":a.getSeconds(),"q+":Math.floor((a.getMonth()+3)/3),S:a.getMilliseconds()},/(y+)/.test(b)&&(b=b.replace(RegExp.$1,(a.getFullYear()+"").substr(4-RegExp.$1.length)));for(d in c)new RegExp("("+d+")").test(b)&&(b=b.replace(RegExp.$1,1==RegExp.$1.length?c[d]:("00"+c[d]).substr((""+c[d]).length)));return b},formatYMD:function(a){return this.format(a,this.FORMAT_YMD)},formatYMDHMD:function(a){return this.format(a,this.FORMAT_YMD_HMS)},formatMD:function(a){return this.format(a,"MM-dd")},isDate:function(a){var c,b=/^(\d{4})-(\d{1,2})-(\d{1,2})$/;return b.test(a)?(c=b.exec(a),this.isMonthAndDateCorrect(c[1],c[2],c[3])):!1},isDateTime:function(a){var c,b=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;return b.test(a)?(c=b.exec(a),this.isMonthAndDateCorrect(c[1],c[2],c[3])?c[4]>=24?!1:c[5]>=60?!1:c[6]>=60?!1:!0:!1):!1},isMonthAndDateCorrect:function(a,b,c){if(b>12||0>=b)return!1;if(c>31||0>=b)return!1;var d=!1;switch(b){case 1:case 3:case 5:case 7:case 8:case 10:case 12:d=!0;break;case 4:case 6:case 9:case 11:d=30>=c}return d?28>=c?!0:this.isLeapYear(a)?29>=c:!1:!0},isLeapYear:function(a){return 0!=a%4?!1:0!=a%100?!0:0==a%400},compare:function(a,b){var c,d;return a=this.parse(a),b=this.parse(b),c=a.getTime(),d=b.getTime(),c==d?0:c>d?1:-1},compareWithNow:function(a){return this.compare(a,new Date)},compareDate:function(a,b){return a==b?this.IS_SAME_DAY:this.compare(new Date(a),new Date(b))},getYesterday:function(){var a=new Date,b=a.getTime();return b-=this.ONE_DAY_TIME,a.setTime(b),this.format(a,this.FORMAT_YMD)},getDate:function(a,b){var c,d;return a=this.parse(a),c=this.clone(a),d=c.getTime(),d+=b*this.ONE_DAY_TIME,c.setTime(d),this.format(c,this.FORMAT_YMD)},clone:function(a){if(a instanceof Date){var b=new Date;return b.setTime(a.getTime()),b}return a},parse:function(a){if(a instanceof Date)return a;if("number"==typeof a)return new Date(a);if("string"==typeof a)return new Date(Date.parse(a.replace(/-/g,"/")));throw new Error("Unable to parse date! Its type isn't supported.")},getDateDiffDay:function(a,b){a=this.parse(a),b=this.parse(b);var c=a.getTime()-b.getTime();return Math.floor(Math.abs(c/this.ONE_DAY_TIME))},getDaysInMonth:function(a,b){var c,d;return b++,12==b&&(a++,b=0),c=new Date(a+"/"+(b+1)+"/1"),b++,12==b&&(a++,b=0),d=new Date(a+"/"+(b+1)+"/1"),this.getDateDiffDay(c,d)},getLastMonth:function(a,b){return 0==b?(a--,b=11):b--,new Date(a,b,1)},getYearWeek:function(a){var b,c;return a=this.parse(a),b=new Date(a.getFullYear(),0,0),c=Math.floor((a.getTime()-b.getTime())/6048e5),c+1},getYearLastWeek:function(a){a=this.parse(a);var b=this.getDate(a,-7);return this.getYearWeek(b)},getFirstDayInCurrentMonth:function(){var a=new Date,b=new Date(a.getFullYear(),a.getMonth(),1);return this.format(b,this.FORMAT_YMD)},today:function(){return this.format(new Date,this.FORMAT_YMD)}};"function"==typeof define?define(function(){return a}):"undefined"!=typeof exports?module.exports=a:window.DateUtil=a}();