/** * @overview datejs * @version 1.0.0-beta-2014-03-25 * @author Gregory Wild-Smith * @copyright 2014 Gregory Wild-Smith * @license MIT * @homepage https://github.com/abritinthebay/datejs */ /* 2014 Gregory Wild-Smith @license MIT @homepage https://github.com/abritinthebay/datejs 2014 Gregory Wild-Smith @license MIT @homepage https://github.com/abritinthebay/datejs */ Date.CultureStrings=Date.CultureStrings||{}; Date.CultureStrings["en-US"]={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",Sunday:"Sunday",Monday:"Monday",Tuesday:"Tuesday",Wednesday:"Wednesday",Thursday:"Thursday",Friday:"Friday",Saturday:"Saturday",Sun:"Sun",Mon:"Mon",Tue:"Tue",Wed:"Wed",Thu:"Thu",Fri:"Fri",Sat:"Sat",Su:"Su",Mo:"Mo",Tu:"Tu",We:"We",Th:"Th",Fr:"Fr",Sa:"Sa",S_Sun_Initial:"S",M_Mon_Initial:"M",T_Tue_Initial:"T",W_Wed_Initial:"W",T_Thu_Initial:"T",F_Fri_Initial:"F",S_Sat_Initial:"S",January:"January", February:"February",March:"March",April:"April",May:"May",June:"June",July:"July",August:"August",September:"September",October:"October",November:"November",December:"December",Jan_Abbr:"Jan",Feb_Abbr:"Feb",Mar_Abbr:"Mar",Apr_Abbr:"Apr",May_Abbr:"May",Jun_Abbr:"Jun",Jul_Abbr:"Jul",Aug_Abbr:"Aug",Sep_Abbr:"Sep",Oct_Abbr:"Oct",Nov_Abbr:"Nov",Dec_Abbr:"Dec",AM:"AM",PM:"PM",firstDayOfWeek:0,twoDigitYearMax:2049,mdy:"mdy","M/d/yyyy":"M/d/yyyy","dddd, MMMM dd, yyyy":"dddd, MMMM dd, yyyy","h:mm tt":"h:mm tt", "h:mm:ss tt":"h:mm:ss tt","dddd, MMMM dd, yyyy h:mm:ss tt":"dddd, MMMM dd, yyyy h:mm:ss tt","yyyy-MM-ddTHH:mm:ss":"yyyy-MM-ddTHH:mm:ss","yyyy-MM-dd HH:mm:ssZ":"yyyy-MM-dd HH:mm:ssZ","ddd, dd MMM yyyy HH:mm:ss":"ddd, dd MMM yyyy HH:mm:ss","MMMM dd":"MMMM dd","MMMM, yyyy":"MMMM, yyyy","/jan(uary)?/":"jan(uary)?","/feb(ruary)?/":"feb(ruary)?","/mar(ch)?/":"mar(ch)?","/apr(il)?/":"apr(il)?","/may/":"may","/jun(e)?/":"jun(e)?","/jul(y)?/":"jul(y)?","/aug(ust)?/":"aug(ust)?","/sep(t(ember)?)?/":"sep(t(ember)?)?", "/oct(ober)?/":"oct(ober)?","/nov(ember)?/":"nov(ember)?","/dec(ember)?/":"dec(ember)?","/^su(n(day)?)?/":"^su(n(day)?)?","/^mo(n(day)?)?/":"^mo(n(day)?)?","/^tu(e(s(day)?)?)?/":"^tu(e(s(day)?)?)?","/^we(d(nesday)?)?/":"^we(d(nesday)?)?","/^th(u(r(s(day)?)?)?)?/":"^th(u(r(s(day)?)?)?)?","/^fr(i(day)?)?/":"^fr(i(day)?)?","/^sa(t(urday)?)?/":"^sa(t(urday)?)?","/^next/":"^next","/^last|past|prev(ious)?/":"^last|past|prev(ious)?","/^(\\+|aft(er)?|from|hence)/":"^(\\+|aft(er)?|from|hence)","/^(\\-|bef(ore)?|ago)/":"^(\\-|bef(ore)?|ago)", "/^yes(terday)?/":"^yes(terday)?","/^t(od(ay)?)?/":"^t(od(ay)?)?","/^tom(orrow)?/":"^tom(orrow)?","/^n(ow)?/":"^n(ow)?","/^ms|milli(second)?s?/":"^ms|milli(second)?s?","/^sec(ond)?s?/":"^sec(ond)?s?","/^mn|min(ute)?s?/":"^mn|min(ute)?s?","/^h(our)?s?/":"^h(our)?s?","/^w(eek)?s?/":"^w(eek)?s?","/^m(onth)?s?/":"^m(onth)?s?","/^d(ay)?s?/":"^d(ay)?s?","/^y(ear)?s?/":"^y(ear)?s?","/^(a|p)/":"^(a|p)","/^(a\\.?m?\\.?|p\\.?m?\\.?)/":"^(a\\.?m?\\.?|p\\.?m?\\.?)","/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/":"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)", "/^\\s*(st|nd|rd|th)/":"^\\s*(st|nd|rd|th)","/^\\s*(\\:|a(?!u|p)|p)/":"^\\s*(\\:|a(?!u|p)|p)",LINT:"LINT",TOT:"TOT",CHAST:"CHAST",NZST:"NZST",NFT:"NFT",SBT:"SBT",AEST:"AEST",ACST:"ACST",JST:"JST",CWST:"CWST",CT:"CT",ICT:"ICT",MMT:"MMT",BIOT:"BST",NPT:"NPT",IST:"IST",PKT:"PKT",AFT:"AFT",MSK:"MSK",IRST:"IRST",FET:"FET",EET:"EET",CET:"CET",UTC:"UTC",GMT:"GMT",CVT:"CVT",GST:"GST",BRT:"BRT",NST:"NST",AST:"AST",EST:"EST",CST:"CST",MST:"MST",PST:"PST",AKST:"AKST",MIT:"MIT",HST:"HST",SST:"SST",BIT:"BIT", CHADT:"CHADT",NZDT:"NZDT",AEDT:"AEDT",ACDT:"ACDT",AZST:"AZST",IRDT:"IRDT",EEST:"EEST",CEST:"CEST",BST:"BST",PMDT:"PMDT",ADT:"ADT",NDT:"NDT",EDT:"EDT",CDT:"CDT",MDT:"MDT",PDT:"PDT",AKDT:"AKDT",HADT:"HADT"};Date.CultureStrings.lang="en-US"; (function(){var f=Date,g=Date.CultureStrings?Date.CultureStrings.lang:null,c={},a=function(a,e){var b,h,f,m=e?e:g;if(Date.CultureStrings&&Date.CultureStrings[m]&&Date.CultureStrings[m][a])b=Date.CultureStrings[m][a];else switch(a){case "name":b="en-US";break;case "englishName":b="English (United States)";break;case "nativeName":b="English (United States)";break;case "twoDigitYearMax":b=2049;break;case "firstDayOfWeek":b=0;break;default:if(b=a,h=a.split("_"),f=h.length,1b?1:0;throw new TypeError(a+" - "+b);};f.equals=function(a,b){return 0===a.compareTo(b)};f.getDayName=function(a){return Date.CultureInfo.dayNames[a]};f.getDayNumberFromName=function(a){var b=Date.CultureInfo.dayNames,d=Date.CultureInfo.abbreviatedDayNames,c=Date.CultureInfo.shortestDayNames; a=a.toLowerCase();for(var h=0;h=a.getTime()&&this.getTime()<=b.getTime()};g.isAfter=function(a){return 1===this.compareTo(a||new Date)};g.isBefore=function(a){return-1===this.compareTo(a||new Date)};g.isToday=g.isSameDay=function(a){return this.clone().clearTime().equals((a||new Date).clone().clearTime())};g.addMilliseconds=function(a){if(!a)return this;this.setTime(this.getTime()+1*a);return this};g.addSeconds=function(a){return a?this.addMilliseconds(1E3*a): this};g.addMinutes=function(a){return a?this.addMilliseconds(6E4*a):this};g.addHours=function(a){return a?this.addMilliseconds(36E5*a):this};g.addDays=function(a){if(!a)return this;this.setDate(this.getDate()+1*a);return this};g.addWeekdays=function(a){if(!a)return this;var b=this.getDay(),d=Math.ceil(Math.abs(a)/7);(0===b||6===b)&&0a){for(;0>a;)this.addDays(-1),b=this.getDay(),0!==b&&6!==b&&a++;return this}if(5d?!1:!0};f.validateMillisecond=function(e){return a(e,0,999,"millisecond")};f.validateSecond=function(e){return a(e,0,59,"second")};f.validateMinute=function(e){return a(e,0,59,"minute")};f.validateHour=function(e){return a(e,0,23,"hour")};f.validateDay=function(e,b,d){return a(e,1,f.getDaysInMonth(b,d),"day")};f.validateWeek=function(e){return a(e,0,53,"week")}; f.validateMonth=function(e){return a(e,0,11,"month")};f.validateYear=function(e){return a(e,-271822,275760,"year")};g.set=function(a){f.validateMillisecond(a.millisecond)&&this.addMilliseconds(a.millisecond-this.getMilliseconds());f.validateSecond(a.second)&&this.addSeconds(a.second-this.getSeconds());f.validateMinute(a.minute)&&this.addMinutes(a.minute-this.getMinutes());f.validateHour(a.hour)&&this.addHours(a.hour-this.getHours());f.validateMonth(a.month)&&this.addMonths(a.month-this.getMonth()); f.validateYear(a.year)&&this.addYears(a.year-this.getFullYear());f.validateDay(a.day,this.getFullYear(),this.getMonth())&&this.addDays(a.day-this.getDate());a.timezone&&this.setTimezone(a.timezone);a.timezoneOffset&&this.setTimezoneOffset(a.timezoneOffset);a.week&&f.validateWeek(a.week)&&this.setWeek(a.week);return this};g.moveToFirstDayOfMonth=function(){return this.set({day:1})};g.moveToLastDayOfMonth=function(){return this.set({day:f.getDaysInMonth(this.getFullYear(),this.getMonth())})};g.moveToNthOccurrence= function(a,b){if("Weekday"===a){if(0b)this.moveToLastDayOfMonth(),this.is().weekday()&&(b+=1);else return this;return this.addWeekdays(b)}var d=0;if(0a)return a=(a-1E4).toString(),a.charAt(0)+ a.substr(2);a=(a+1E4).toString();return"+"+a.substr(1)};g.getElapsed=function(a){return(a||new Date)-this};var b=function(a){switch(1*a){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}};g.toString=function(a,f){var d=this;if(!f&&a&&1===a.length){var g,h=Date.CultureInfo.formatPatterns;d.t=d.toString;switch(a){case "d":return d.t(h.shortDate);case "D":return d.t(h.longDate);case "F":return d.t(h.fullDateTime);case "m":return d.t(h.monthDay); case "r":case "R":return g=d.clone().addMinutes(d.getTimezoneOffset()),g.toString(h.rfc1123)+" GMT";case "s":return d.t(h.sortableDateTime);case "t":return d.t(h.shortTime);case "T":return d.t(h.longTime);case "u":return g=d.clone().addMinutes(d.getTimezoneOffset()),g.toString(h.universalSortableDateTime);case "y":return d.t(h.yearMonth)}}return a?a.replace(/((\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S|q|Q|WW?W?W?)(?![^\[]*\]))/g,function(a){if("\\"===a.charAt(0))return a.replace("\\",""); d.h=d.getHours;switch(a){case "hh":return c(13>d.h()?0===d.h()?12:d.h():d.h()-12);case "h":return 13>d.h()?0===d.h()?12:d.h():d.h()-12;case "HH":return c(d.h());case "H":return d.h();case "mm":return c(d.getMinutes());case "m":return d.getMinutes();case "ss":return c(d.getSeconds());case "s":return d.getSeconds();case "yyyy":return c(d.getFullYear(),4);case "yy":return c(d.getFullYear());case "dddd":return Date.CultureInfo.dayNames[d.getDay()];case "ddd":return Date.CultureInfo.abbreviatedDayNames[d.getDay()]; case "dd":return c(d.getDate());case "d":return d.getDate();case "MMMM":return Date.CultureInfo.monthNames[d.getMonth()];case "MMM":return Date.CultureInfo.abbreviatedMonthNames[d.getMonth()];case "MM":return c(d.getMonth()+1);case "M":return d.getMonth()+1;case "t":return 12>d.h()?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case "tt":return 12>d.h()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case "S":return b(d.getDate());case "W":return d.getWeek(); case "WW":return d.getISOWeek();case "Q":return"Q"+d.getQuarter();case "q":return String(d.getQuarter());default:return a}}).replace(/\[|\]/g,""):this._toString()}})(); (function(){Date.Parsing={Exception:function(a){this.message="Parse error at '"+a.substring(0,10)+" ...'"}};var f=Date.Parsing,g=[0,31,59,90,120,151,181,212,243,273,304,334],c=[0,31,60,91,121,152,182,213,244,274,305,335];f.isLeapYear=function(a){return 0===a%4&&0!==a%100||0===a%400};f.processTimeObject=function(a){var b,e;b=new Date;e=f.isLeapYear(a.year)?c:g;a.hours=a.hours?a.hours:0;a.minutes=a.minutes?a.minutes:0;a.seconds=a.seconds?a.seconds:0;a.milliseconds=a.milliseconds?a.milliseconds:0;a.year|| (a.year=b.getFullYear());if(a.month||!a.week&&!a.dayOfYear)a.month=a.month?a.month:0,a.day=a.day?a.day:1,a.dayOfYear=e[a.month]+a.day;else for(a.dayOfYear||(a.weekDay=a.weekDay||0===a.weekDay?a.weekDay:1,b=new Date(a.year,0,4),b=0===b.getDay()?7:b.getDay(),a.dayOfYear=7*a.week+(0===a.weekDay?7:a.weekDay)-(b+3)),b=0;b<=e.length;b++)if(a.dayOfYeara.length)return e.year=a,f.processTimeObject(e);a=a.match(this.regex);if(!a||!a.length)return null;for(b=0;bthis.day)throw"invalid day";}},month:function(a){return function(){this.month=3===a.length?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(a)/4:Number(a)-1;if(0>this.month)throw"invalid month";}},year:function(a){return function(){var b= Number(a);this.year=2this.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"==this.meridian&&12>this.hour?this.hour+=12: "a"==this.meridian&&12==this.hour&&(this.hour=0)}if(this.day>f.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");a=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);100>this.year&&a.setFullYear(this.year);this.timezone?a.set({timezone:this.timezone}):this.timezoneOffset&&a.set({timezoneOffset:this.timezoneOffset});return a},finish:function(a){a=a instanceof Array?g(a):[a];if(0===a.length)return null;for(var b= 0;bthis.hour&&Date.Config.strict24hr)throw"Invalid hour and meridian combination";"p"==this.meridian&&12>this.hour?this.hour+=12:"a"==this.meridian&& 12==this.hour&&(this.hour=0)}!this.weekday||"week"===this.unit||this.day||this.days||(c=Date[this.weekday](),this.day=c.getDate(),c.getMonth()!==a.getMonth()&&(this.month=c.getMonth()));!this.month&&0!==this.month||this.day||(this.day=1);if(!this.orient&&!this.operator&&"week"==this.unit&&this.value&&!this.day&&!this.month)return Date.today().setWeek(this.value);if("week"==this.unit&&this.weeks&&!this.day&&!this.month)return a=Date[this.weekday?this.weekday:"today"]().addWeeks(this.weeks),this.now&& a.setTimeToNow(),a;b&&this.timezone&&this.day&&this.days&&(this.day=this.days);return b?a.add(this):a.set(this)}};var c=f.Parsing.Operators,a=f.Grammar,b=f.Translator,e;a.datePartDelimiter=c.rtoken(/^([\s\-\.\,\/\x27]+)/);a.timePartDelimiter=c.stoken(":");a.whiteSpace=c.rtoken(/^\s*/);a.generalDelimiter=c.rtoken(/^(([\s\,]|at|@|on)+)/);var q={};a.ctoken=function(a){var b=q[a];if(!b){for(var b=Date.CultureInfo.regexPatterns,d=a.split(/\s+/),e=[],f=0;fc)throw new RangeError(f.getDayName(a)+ " does not occur "+b+" times in the month of "+f.getMonthName(c.getMonth())+" "+c.getFullYear()+".");return this}return this.moveToDayOfWeek(a,this._orient)}},h=function(a){return function(){var b=f.today(),c=a-b.getDay();0===a&&1===Date.CultureInfo.firstDayOfWeek&&0!==b.getDay()&&(c+=7);return b.addDays(c)}},k=0;kf?-1:1,this.setMilliseconds(Math.abs(f)),this.setDays(Math.floor(this.getMilliseconds()/864E5)*e),this.setMilliseconds(this.getMilliseconds()%864E5),this.setHours(Math.floor(this.getMilliseconds()/36E5)*e),this.setMilliseconds(this.getMilliseconds()%36E5),this.setMinutes(Math.floor(this.getMilliseconds()/6E4)*e),this.setMilliseconds(this.getMilliseconds()%6E4),this.setSeconds(Math.floor(this.getMilliseconds()/ 1E3)*e),this.setMilliseconds(this.getMilliseconds()%1E3),this.setMilliseconds(this.getMilliseconds()*e));this.getTotalMilliseconds=function(){return 864E5*this.getDays()+36E5*this.getHours()+6E4*this.getMinutes()+1E3*this.getSeconds()};this.compareTo=function(a){var b=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds());a=null===a?new Date(1970,1,1,0,0,0):new Date(1970,1,1,a.getHours(),a.getMinutes(),a.getSeconds());return ba?1:0};this.equals=function(a){return 0===this.compareTo(a)}; this.add=function(a){return null===a?this:this.addSeconds(a.getTotalMilliseconds()/1E3)};this.subtract=function(a){return null===a?this:this.addSeconds(-a.getTotalMilliseconds()/1E3)};this.addDays=function(a){return new TimeSpan(this.getTotalMilliseconds()+864E5*a)};this.addHours=function(a){return new TimeSpan(this.getTotalMilliseconds()+36E5*a)};this.addMinutes=function(a){return new TimeSpan(this.getTotalMilliseconds()+6E4*a)};this.addSeconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+ 1E3*a)};this.addMilliseconds=function(a){return new TimeSpan(this.getTotalMilliseconds()+a)};this.get12HourHour=function(){return 12this.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator};this.toString=function(a){this._toString=function(){return null!==this.getDays()&&0a.toString().length?"0"+a:a};var b=this;return a?a.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g,function(a){switch(a){case "d":return b.getDays();case "dd":return b.p(b.getDays());case "H":return b.getHours();case "HH":return b.p(b.getHours());case "h":return b.get12HourHour();case "hh":return b.p(b.get12HourHour());case "m":return b.getMinutes();case "mm":return b.p(b.getMinutes());case "s":return b.getSeconds(); case "ss":return b.p(b.getSeconds());case "t":return(12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case "tt":return 12>b.getHours()?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator}}):this._toString()};return this};Date.prototype.getTimeOfDay=function(){return new TimeSpan(0,this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds())}; var TimePeriod=function(f,g,c,a,b,e,q){for(var d="years months days hours minutes seconds milliseconds".split(/\s+/),l=function(a){return function(){return this[a]}},h=function(a){return function(b){this[a]=b;return this}},k=0;kl?-1:1;this.years=l.getFullYear()-d.getFullYear();h.addYears(this.years);1===k?h>l&&0!==this.years&&this.years--:hl&&d.clone().addDays(-d.getDaysInMonth())>l;)d.addMonths(-1),this.months--;d=l-d;0!==d&&(d=new TimeSpan(d), this.setDays(d.getDays()),this.setHours(d.getHours()),this.setMinutes(d.getMinutes()),this.setSeconds(d.getSeconds()),this.setMilliseconds(d.getMilliseconds()))}return this};