Date.DAYNAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.MONTHNAMES=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.msPERDAY=1000*60*60*24;Date.prototype.DAYNAMES=Date.DAYNAMES;Date.prototype.MONTHNAMES=Date.MONTHNAMES;Date.prototype.msPERDAY=Date.msPERDAY;Date.prototype.copy=function(){return new Date(this.getTime())};Date.prototype.getFullDay=function(){return this.DAYNAMES[this.getDay()]};Date.prototype.getDayAbbr=function(){return this.getFullDay().slice(0,3)};Date.prototype.getFullMonth=function(){return this.MONTHNAMES[this.getMonth()]};Date.prototype.getMonthAbbr=function(){return this.getFullMonth().slice(0,3)};Date.prototype.to12HourTimeString=function(){var D=this.getHours();var A="0"+this.getMinutes();var C="0"+this.getSeconds();var B="am";if(D>=12){B="pm";if(D>=13){D-=12}}else{if(D==0){D=12}}D="0"+D;return D.slice(-2)+":"+A.slice(-2)+":"+C.slice(-2)+" "+B};Date.prototype.to24HourTimeString=function(){var C="0"+this.getHours();var A="0"+this.getMinutes();var B="0"+this.getSeconds();return C.slice(-2)+":"+A.slice(-2)+":"+B.slice(-2)};Date.prototype.lastday=function(){var A=new Date(this.getFullYear(),this.getMonth()+1,0);return A.getDate()};Date.prototype.getDaysBetween=function(C){var A=C.copy();A.setHours(this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds());var B=A.getTime()-this.getTime();return B/this.msPERDAY};Date.prototype.getDayOfYear=function(){var A=new Date(this.getFullYear(),0,0);return this.getDaysBetween(A)*-1};Date.prototype.addDays=function(A){this.setDate(this.getDate()+A)};Date.prototype.addWeeks=function(A){this.addDays(A*7)};Date.prototype.addMonths=function(A){var B=this.getDate();this.setMonth(this.getMonth()+A);if(this.getDate()<B){this.setDate(0)}};Date.prototype.addYears=function(B){var A=this.getMonth();this.setFullYear(this.getFullYear()+B);if(A<this.getMonth()){this.setDate(0)}};Date.prototype.addWeekDays=function(E){var D=this.getDay();var C=0;var B=E%5;if(E<0){C=Math.ceil(E/5);switch(D){case 6:if(B==0&&C<0){C++}break;case 0:if(B==0){E++}else{E--}break;default:if(B<=-D){C--}}}else{if(E>0){C=Math.floor(E/5);var A=C;switch(D){case 6:if(B==0){E--}else{E++}break;case 0:if(B==0&&C>0){C--}break;default:if(5-day<B){C++}}}}E+=C*2;this.addDays(E)};Date.prototype.getWeekDays=function(D){var C=0;var E=Math.abs(this.getDaysBetween(D));var B=0,A=0;if(E){if(D<this){B=D.getDay();A=this.getDay()}else{B=this.getDay();A=D.getDay()}C=Math.floor(E/7);if(B!=6&&B>A){C++}if(B!=A&&(B==6||A==6)){E--}E-=(C*2)}return E};Date.prototype.getMonthsBetween=function(G){var F,J;var B=this.getFullYear()*12+this.getMonth();var A=G.getFullYear()*12+G.getMonth();var D;var C=0;if(this==G){C=0}else{if(B==A){C=(G.getDate()-this.getDate())/this.lastday()}else{if(B<A){F=this;J=G;D=1}else{F=G;J=this;D=-1}var I=F.lastday()-F.getDate();var E=J.getDate();var H=(I+E)/F.lastday()-1;C=Math.abs(A-B)+H;C=(C*D)}}return C};Date.prototype.getYearsBetween=function(B){var A=this.getMonthsBetween(B);return A/12};Date.prototype.getAge=function(){var A=new Date();return this.getYearsBetween(A).toFixed(2)};Date.prototype.sameDayEachWeek=function(C,D){var E=new Array();var A,F,B;if(this>D){A=this;F=D.copy()}else{A=D;F=this.copy()}B=(C-F.getDay()+7)%7;F.setDate(F.getDate()+B);while(F<A){E[E.length]=F.copy();F.setDate(F.getDate()+7)}return E};Date.toDate=function(D){var A;if(arguments.length==0){A=new Date()}else{if(D instanceof Date){A=new Date(D.getTime())}else{if(typeof D=="string"){A=new Date(D)}else{if(arguments.length>=3){var C=[0,0,0,0,0,0];for(var B=0;B<arguments.length&&B<7;B++){C[B]=arguments[B]}A=new Date(C[0],C[1],C[2],C[3],C[4],C[5])}else{if(typeof D=="number"){A=new Date(D)}else{A=null}}}}}if(A=="Invalid Date"){return null}else{return A}};
