function Now(){return new Date()}var JANUARY=0;var FEBRUARY=1;var MARCH=2;var APRIL=3;var MAY=4;var JUNE=5;var JULY=6;var AUGUST=7;var SEPTEMBER=8;var OCTOBER=9;var NOVEMBER=10;var DECEMBER=11;var SUNDAY=0;var MONDAY=1;var TUESDAY=2;var WEDNESDAY=3;var THURSDAY=4;var FRIDAY=5;var SATURDAY=6;var SECONDS_CF=1000;var MINUTES_CF=60000;var HOURS_CF=3600000;var DAYS_CF=86400000;var WEEKS_CF=604800000;var FORTNIGHTS_CF=1209600000;var MONTHS_CF=2592000000;var QUARTERS_CF=7776000000;var YEARS_CF=31557600000;var DECADES_CF=315576000000;var CENTURIES_CF=3155760000000;Date.prototype.addMilliseconds=function(A){return new Date(new Date().setTime(this.getTime()+(A)))};Date.prototype.addSeconds=function(A){return this.addMilliseconds(A*SECONDS_CF)};Date.prototype.addMinutes=function(A){return this.addMilliseconds(A*MINUTES_CF)};Date.prototype.addHours=function(A){return this.addMilliseconds(A*HOURS_CF)};Date.prototype.addDays=function(A){return this.addMilliseconds(A*DAYS_CF)};Date.prototype.addWeeks=function(A){return this.addMilliseconds(A*WEEKS_CF)};Date.prototype.addFortnights=function(A){return this.addMilliseconds(A*FORTNIGHTS_CF)};Date.prototype.addMonths=function(A){return this.addMilliseconds(A*MONTHS_CF)};Date.prototype.addYears=function(A){return this.addMilliseconds(A*YEARS_CF)};Date.prototype.subtractMilliseconds=function(A){return new Date(new Date().setTime(this.getTime()-(A)))};Date.prototype.subtractSeconds=function(A){return this.subtractMilliseconds(A*SECONDS_CF)};Date.prototype.subtractMinutes=function(A){return this.subtractMilliseconds(A*MINUTES_CF)};Date.prototype.subtractHours=function(A){return this.subtractMilliseconds(A*HOURS_CF)};Date.prototype.subtractDays=function(A){return this.subtractMilliseconds(A*DAYS_CF)};Date.prototype.subtractWeeks=function(A){return this.subtractMilliseconds(A*WEEKS_CF)};Date.prototype.subtractFortnights=function(A){return this.subtractMilliseconds(A*FORTNIGHTS_CF)};Date.prototype.subtractMonths=function(A){return this.subtractMilliseconds(A*MONTHS_CF)};Date.prototype.subtractYears=function(A){return this.subtractMilliseconds(A*YEARS_CF)};Date.prototype._addMilliseconds=function(A){this.setTime(this.getTime()+(A));return this};Date.prototype._addSeconds=function(A){return this._addMilliseconds(A*SECONDS_CF)};Date.prototype._addMinutes=function(A){return this._addMilliseconds(A*MINUTES_CF)};Date.prototype._addHours=function(A){return this._addMilliseconds(A*HOURS_CF)};Date.prototype._addDays=function(A){return this._addMilliseconds(A*DAYS_CF)};Date.prototype._addWeeks=function(A){return this._addMilliseconds(A*WEEKS_CF)};Date.prototype._addFortnights=function(A){return this._addMilliseconds(A*FORTNIGHTS_CF)};Date.prototype._addMonths=function(A){return this._addMilliseconds(A*MONTHS_CF)};Date.prototype._addYears=function(A){return this._addMilliseconds(A*YEARS_CF)};Date.prototype._subtractMilliseconds=function(A){this.setTime(this.getTime()-(A));return this};Date.prototype._subtractSeconds=function(A){return this._subtractMilliseconds(A*SECONDS_CF)};Date.prototype._subtractMinutes=function(A){return this._subtractMilliseconds(A*MINUTES_CF)};Date.prototype._subtractHours=function(A){return this._subtractMilliseconds(A*HOURS_CF)};Date.prototype._subtractDays=function(A){return this._subtractMilliseconds(A*DAYS_CF)};Date.prototype._subtractWeeks=function(A){return this._subtractMilliseconds(A*WEEKS_CF)};Date.prototype._subtractFortnights=function(A){return this._subtractMilliseconds(A*FORTNIGHTS_CF)};Date.prototype._subtractMonths=function(A){return this._subtractMilliseconds(A*MONTHS_CF)};Date.prototype._subtractYears=function(A){return this._subtractMilliseconds(A*YEARS_CF)};Date.prototype.getMonthName=function(){var A=(0==arguments.length)?this.getMonth():arguments[0];switch(A){case JANUARY:return"January";case FEBRUARY:return"February";case MARCH:return"March";case APRIL:return"April";case MAY:return"May";case JUNE:return"June";case JULY:return"July";case AUGUST:return"August";case SEPTEMBER:return"September";case OCTOBER:return"October";case NOVEMBER:return"November";case DECEMBER:return"December";default:throw"Invalid month index: "+A.toString()}};Date.prototype.getMonthAbbreviation=function(){var A=(0==arguments.length)?this.getMonth():arguments[0];switch(A){case JANUARY:return"Jan";case FEBRUARY:return"Feb";case MARCH:return"Mar";case APRIL:return"Apr";case MAY:return"May";case JUNE:return"Jun";case JULY:return"Jul";case AUGUST:return"Aug";case SEPTEMBER:return"Sep";case OCTOBER:return"Oct";case NOVEMBER:return"Nov";case DECEMBER:return"Dec";default:throw"Invalid month index: "+A.toString()}};Date.prototype.getDayName=function(){var A=(0==arguments.length)?this.getDay():arguments[0];switch(A){case SUNDAY:return"Sunday";case MONDAY:return"Monday";case TUESDAY:return"Tuesday";case WEDNESDAY:return"Wednesday";case THURSDAY:return"Thursday";case FRIDAY:return"Friday";case SATURDAY:return"Saturday";default:throw"Invalid day index: "+A.toString()}};Date.prototype.getDayAbbreviation=function(){var A=(0==arguments.length)?this.getDay():arguments[0];switch(A){case SUNDAY:return"Sun";case MONDAY:return"Mon";case TUESDAY:return"Tue";case WEDNESDAY:return"Wed";case THURSDAY:return"Thu";case FRIDAY:return"Fri";case SATURDAY:return"Sat";default:throw"Invalid day index: "+A.toString()}};Date.prototype.getCivilianHours=function(){return(this.getHours()<12)?this.getHours():this.getHours()-12};Date.prototype.getMeridiem=function(){return(this.getHours()<12)?"AM":"PM"};Date.prototype.to_s=Date.prototype.toString;Date.prototype.format=function(A){A=A.replace(/%YYYY/,this.getFullYear().toString());A=A.replace(/%YY/,this.getFullYear().toString().substr(2,2));A=A.replace(/%MMMM/,this.getMonthName(this.getMonth()).toString());A=A.replace(/%MMM/,this.getMonthAbbreviation(this.getMonth()).toString());A=A.replace(/%MM/,(this.getMonth()+1)>9?(this.getMonth()+1).toString():"0"+(this.getMonth()+1).toString());A=A.replace(/%M/,(this.getMonth()+1).toString());A=A.replace(/%DDDD/,this.getDayName(this.getDay()).toString());A=A.replace(/%DDD/,this.getDayAbbreviation(this.getDay()).toString());A=A.replace(/%DD/,this.getDate()>9?this.getDate().toString():"0"+this.getDate().toString());A=A.replace(/%D/,this.getDate().toString());A=A.replace(/%HH/,this.getHours()>9?this.getHours().toString():"0"+this.getHours().toString());A=A.replace(/%H/,this.getHours().toString());A=A.replace(/%hh/,this.getCivilianHours()>9?this.getCivilianHours().toString():"0"+this.getCivilianHours().toString());A=A.replace(/%h/,this.getCivilianHours());A=A.replace(/%mm/,this.getMinutes()>9?this.getMinutes().toString():"0"+this.getMinutes().toString());A=A.replace(/%m/,this.getMinutes().toString());A=A.replace(/%ss/,this.getSeconds()>9?this.getSeconds().toString():"0"+this.getSeconds().toString());A=A.replace(/%s/,this.getSeconds().toString());A=A.replace(/%nnn/,this.getMilliseconds().toString());A=A.replace(/%p/,this.getMeridiem());return A};Date.prototype.getDaysInMonth=function(){switch(this.getMonth()){case JANUARY:return 31;case FEBRUARY:return this.isLeapYear()?29:28;case MARCH:return 31;case APRIL:return 30;case MAY:return 31;case JUNE:return 30;case JULY:return 31;case AUGUST:return 31;case SEPTEMBER:return 30;case OCTOBER:return 31;case NOVEMBER:return 30;case DECEMBER:return 31}};Date.prototype.toString=function(){if(0==arguments.length||1<arguments.length){return this.to_s()}return this.format(arguments[0].toString())};Date.prototype.isLeapYear=function(){if(0==this.getFullYear()%400){return true}if(0==this.getFullYear()%100){return false}return(0==this.getFullYear()%4)?true:false};Date.prototype.zeroTime=function(){var A=this.clone();A.setHours(0);A.setMinutes(0);A.setSeconds(0);A.setMilliseconds(0);return A};Date.prototype.noon=function(){var A=this.clone();A.setHours(12);A.setMinutes(0);A.setSeconds(0);A.setMilliseconds(0);return A};Date.prototype.firstDayOfMonth=function(){return new Date(this.getFullYear(),this.getMonth(),1,12,0,0)};Date.prototype.lastDayOfMonth=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDaysInMonth(),12,0,0)};Date.prototype.clone=function(){var A=new Date();A.setTime(this.getTime());return A};Date.yesterday=function(){return new Date().noon().subtractDays(1)};Date.today=function(){return new Date().noon()};Date.tomorrow=function(){return new Date().noon().addDays(1)};Date.lastWeek=function(){return new Date().noon().subtractWeeks(1)};Date.nextWeek=function(){return new Date().noon().addWeeks(1)};Date.lastMonth=function(){return new Date().noon().subtractMonths(1)};Date.nextFortnight=function(){return new Date().noon().addFortnights(1)};Date.lastFortnight=function(){return new Date().noon().subtractFortnights(1)};Date.nextMonth=function(){return new Date().noon().addMonths(1)};Date.lastYear=function(){return new Date().noon().subtractYears(1)};Date.nextYear=function(){return new Date().noon().addYears(1)};Number.prototype.millisecondsFromNow=function(){return new Date().addMilliseconds(this)};Number.prototype.millisecondFromNow=function(){return this.millisecondsFromNow()};Number.prototype.secondsFromNow=function(){return new Date().addSeconds(this)};Number.prototype.secondFromNow=function(){return this.secondsFromNow()};Number.prototype.minutesFromNow=function(){return new Date().addMinutes(this)};Number.prototype.minuteFromNow=function(){return this.minutesFromNow()};Number.prototype.daysFromNow=function(){return new Date().addDays(this)};Number.prototype.dayFromNow=function(){return this.daysFromNow()};Number.prototype.weeksFromNow=function(){return new Date().addWeeks(this)};Number.prototype.weekFromNow=function(){return this.weeksFromNow()};Number.prototype.fortnightsFromNow=function(){return new Date().addFortnights(this)};Number.prototype.fortnightFromNow=function(){return this.fortnightsFromNow()};Number.prototype.monthsFromNow=function(){return new Date().addMonths(this)};Number.prototype.monthFromNow=function(){return this.monthsFromNow()};Number.prototype.yearsFromNow=function(){return new Date().addYears(this)};Number.prototype.yearFromNow=function(){return this.yearsFromNow()};Number.prototype.millisecondsAgo=function(){return new Date().subtractMilliSeconds(this)};Number.prototype.millisecondAgo=function(){return this.millisecondsAgo()};Number.prototype.secondsAgo=function(){return new Date().subtractSeconds(this)};Number.prototype.secondAgo=function(){return this.secondsAgo()};Number.prototype.minutesAgo=function(){return new Date().subtractMinutes(this)};Number.prototype.minuteAgo=function(){return this.minutesAgo()};Number.prototype.hoursAgo=function(){return new Date().subtractHours(this)};Number.prototype.hourAgo=function(){return this.hoursAgo()};Number.prototype.daysAgo=function(){return new Date().subtractDays(this)};Number.prototype.dayAgo=function(){return this.daysAgo()};Number.prototype.weeksAgo=function(){return new Date().subtractWeeks(this)};Number.prototype.weekAgo=function(){return this.weeksAgo()};Number.prototype.fortnightsAgo=function(){return new Date().subtractFortnights(this)};Number.prototype.fortnightAgo=function(){return this.fortnightsAgo()};Number.prototype.monthsAgo=function(){return new Date().subtractMonths(this)};Number.prototype.monthAgo=function(){return this.monthsAgo()};Number.prototype.yearsAgo=function(){return new Date().subtractYears(this)};Number.prototype.yearAgo=function(){return this.yearsAgo()};function TimeSpan(A){this.milliseconds=Math.abs(A);this.seconds=Math.round(this.milliseconds/SECONDS_CF);this.minutes=Math.round(this.milliseconds/MINUTES_CF);this.hours=Math.round(this.milliseconds/HOURS_CF);this.days=Math.round(this.milliseconds/DAYS_CF);this.weeks=Math.round(this.milliseconds/WEEKS_CF);this.fortnights=Math.round(this.milliseconds/FORTNIGHTS_CF);this.months=Math.round(this.milliseconds/MONTHS_CF);this.quarters=Math.round(this.milliseconds/QUARTERS_CF);this.years=Math.round(this.milliseconds/YEARS_CF);this.decades=Math.round(this.milliseconds/DECADES_CF);this.centuries=Math.round(this.milliseconds/CENTURIES_CF)}TimeSpan.prototype.toString=function(){return this.milliseconds.toString()};
