/** * Version: 1.0 Alpha-1 * Build Date: 13-Nov-2007 * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ */ Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],abbreviatedQuarterNames:["Q1","Q2","Q3","Q4"],quarterNames:["1st quarter","2nd quarter","3rd quarter","4th quarter"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}}; Date.getMonthNumberFromName=function(e){var t=Date.CultureInfo.monthNames,n=Date.CultureInfo.abbreviatedMonthNames,r=e.toLowerCase();for(var i=0;ie?1:this=e.getTime()&&n<=t.getTime()},Date.prototype.addMilliseconds=function(e){return this.setMilliseconds(this.getMilliseconds()+e),this},Date.prototype.addSeconds=function(e){return this.addMilliseconds(e*1e3)},Date.prototype.addMinutes=function(e){return this.addMilliseconds(e*6e4)},Date.prototype.addHours=function(e){return this.addMilliseconds(e*36e5)},Date.prototype.addDays=function(e){return this.addMilliseconds(e*864e5)},Date.prototype.addWeeks=function(e){return this.addMilliseconds(e*6048e5)},Date.prototype.addMonths=function(e){var t=this.getDate();return this.setDate(1),this.setMonth(this.getMonth()+e),this.setDate(Math.min(t,this.getDaysInMonth())),this},Date.prototype.addQuarters=function(e){return this.addMonths(e*3)},Date.prototype.addYears=function(e){return this.addMonths(e*12)},Date.prototype.add=function(e){if(typeof e=="number")return this._orient=e,this;var t=e;return(t.millisecond||t.milliseconds)&&this.addMilliseconds(t.millisecond||t.milliseconds),(t.second||t.seconds)&&this.addSeconds(t.second||t.seconds),(t.minute||t.minutes)&&this.addMinutes(t.minute||t.minutes),(t.hour||t.hours)&&this.addHours(t.hour||t.hours),(t.month||t.months)&&this.addMonths(t.month||t.months),(t.year||t.years)&&this.addYears(t.year||t.years),(t.day||t.days)&&this.addDays(t.day||t.days),this},Date._validate=function(e,t,n,r){if(typeof e!="number")throw new TypeError(e+" is not a Number.");if(en)throw new RangeError(e+" is not a valid value for "+r+".");return!0},Date.validateMillisecond=function(e){return Date._validate(e,0,999,"milliseconds")},Date.validateSecond=function(e){return Date._validate(e,0,59,"seconds")},Date.validateMinute=function(e){return Date._validate(e,0,59,"minutes")},Date.validateHour=function(e){return Date._validate(e,0,23,"hours")},Date.validateDay=function(e,t,n){return Date._validate(e,1,Date.getDaysInMonth(t,n),"days")},Date.validateMonth=function(e){return Date._validate(e,0,11,"months")},Date.validateYear=function(e){return Date._validate(e,1,9999,"seconds")},Date.prototype.set=function(e){var t=e;return!t.millisecond&&t.millisecond!==0&&(t.millisecond=-1),!t.second&&t.second!==0&&(t.second=-1),!t.minute&&t.minute!==0&&(t.minute=-1),!t.hour&&t.hour!==0&&(t.hour=-1),!t.day&&t.day!==0&&(t.day=-1),!t.month&&t.month!==0&&(t.month=-1),!t.year&&t.year!==0&&(t.year=-1),t.millisecond!=-1&&Date.validateMillisecond(t.millisecond)&&this.addMilliseconds(t.millisecond-this.getMilliseconds()),t.second!=-1&&Date.validateSecond(t.second)&&this.addSeconds(t.second-this.getSeconds()),t.minute!=-1&&Date.validateMinute(t.minute)&&this.addMinutes(t.minute-this.getMinutes()),t.hour!=-1&&Date.validateHour(t.hour)&&this.addHours(t.hour-this.getHours()),t.month!==-1&&Date.validateMonth(t.month)&&this.addMonths(t.month-this.getMonth()),t.year!=-1&&Date.validateYear(t.year)&&this.addYears(t.year-this.getFullYear()),t.day!=-1&&Date.validateDay(t.day,this.getFullYear(),this.getMonth())&&this.addDays(t.day-this.getDate()),t.timezone&&this.setTimezone(t.timezone),t.timezoneOffset&&this.setTimezoneOffset(t.timezoneOffset),this},Date.prototype.clearTime=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this},Date.prototype.isLeapYear=function(){var e=this.getFullYear();return e%4===0&&e%100!==0||e%400===0},Date.prototype.isWeekday=function(){return!this.is().sat()&&!this.is().sun()},Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth())},Date.prototype.getQuarter=function(){return Math.floor((this.getMonth()+1)/3)},Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1})},Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()})},Date.prototype.moveToDayOfWeek=function(e,t){var n=(e-this.getDay()+7*(t||1))%7;return this.addDays(n===0?n+=7*(t||1):n)},Date.prototype.moveToMonth=function(e,t){var n=(e-this.getMonth()+12*(t||1))%12;return this.addMonths(n===0?n+=12*(t||1):n)},Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/864e5)},Date.prototype.getWeekOfYear=function(e){return this.getWeek();var t,n,r,i,s,o,u},Date.prototype.getWeek=function(e,t,n){var r,i,s,o,u,a,f,l,c,h,p=this;return Date.CultureInfo.firstDayOfWeek!==1&&(this.getDay()===0||!(this.getDay()364+c?h=1:h=(l/7|0)+1,e=t=n=null,h},Date.prototype.getISOWeek=function(){var e=this.getUTCFullYear(),t=this.getUTCMonth()+1,n=this.getUTCDate();return this.getWeek(e,t,n)},Date.prototype.isDST=function(){return console.log("isDST"),this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D"},Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST())},Date.prototype.setTimezoneOffset=function(e){var t=this.getTimezoneOffset(),n=Number(e)*-6/10;return this.addMinutes(n-t),this},Date.prototype.setTimezone=function(e){return this.setTimezoneOffset(Date.getTimezoneOffset(e))},Date.prototype.getUTCOffset=function(){var e=this.getTimezoneOffset()*-10/6,t;return e<0?(t=(e-1e4).toString(),t[0]+t.substr(2)):(t=(e+1e4).toString(),"+"+t.substr(1))},Date.prototype.getDayName=function(e){return e?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()]},Date.prototype.getMonthName=function(e){return e?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()]},Date.prototype._toString=Date.prototype.toString,Date.prototype.toString=function(e){var t=this,n=function(t){return t.toString().length==1?"0"+t:t};return e?e.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(e){switch(e){case"hh":return n(t.getHours()<13?t.getHours():t.getHours()-12);case"h":return t.getHours()<13?t.getHours():t.getHours()-12;case"HH":return n(t.getHours());case"H":return t.getHours();case"mm":return n(t.getMinutes());case"m":return t.getMinutes();case"ss":return n(t.getSeconds());case"s":return t.getSeconds();case"yyyy":return t.getFullYear();case"yy":return t.getFullYear().toString().substring(2,4);case"dddd":return t.getDayName();case"ddd":return t.getDayName(!0);case"dd":return n(t.getDate());case"d":return t.getDate().toString();case"MMMM":return t.getMonthName();case"MMM":return t.getMonthName(!0);case"MM":return n(t.getMonth()+1);case"M":return t.getMonth()+1;case"t":return t.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return t.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return""}}):this._toString()}; Date.now=function(){return new Date},Date.today=function(){return Date.now().clearTime()},Date.prototype._orient=1,Date.prototype.next=function(){return this._orient=1,this},Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){return this._orient=-1,this},Date.prototype._is=!1,Date.prototype.is=function(){return this._is=!0,this},Number.prototype._dateElement="day",Number.prototype.fromNow=function(){var e={};return e[this._dateElement]=this,Date.now().add(e)},Number.prototype.ago=function(){var e={};return e[this._dateElement]=this*-1,Date.now().add(e)},function(){var e=Date.prototype,t=Number.prototype,n="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),r="january february march april may june july august september october november december".split(/\s/),i="Millisecond Second Minute Hour Day Week Month Year".split(/\s/),s,o=function(e){return function(){return this._is?(this._is=!1,this.getDay()==e):this.moveToDayOfWeek(e,this._orient)}};for(var u=0;u0&&!h)try{a=r.call(this,o[1])}catch(m){h=!0}else h=!0;!h&&a[1].length===0&&(h=!0);if(!h){var g=[];for(var y=0;y0&&(f[0]=f[0].concat(u[0]),f[1]=u[1])}f[1].length1?t=Array.prototype.slice.call(arguments):arguments[0]instanceof Array&&(t=arguments[0]);if(!t)return e.apply(null,arguments);for(var r=0,i=t.shift();r2?t:t+(t+2e3Date.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);return this.timezone?r.set({timezone:this.timezone}):this.timezoneOffset&&r.set({timezoneOffset:this.timezoneOffset}),r},finish:function(t){t=t instanceof Array?e(t):[t];if(t.length===0)return null;for(var n=0;n