/**
 * 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"],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;i<t.length;i++){if(t[i].toLowerCase()==r||n[i].toLowerCase()==r){return i}}return-1};Date.getDayNumberFromName=function(e){var t=Date.CultureInfo.dayNames,n=Date.CultureInfo.abbreviatedDayNames,r=Date.CultureInfo.shortestDayNames,i=e.toLowerCase();for(var s=0;s<t.length;s++){if(t[s].toLowerCase()==i||n[s].toLowerCase()==i){return s}}return-1};Date.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0};Date.getDaysInMonth=function(e,t){return[31,Date.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]};Date.getTimezoneOffset=function(e,t){return t||false?Date.CultureInfo.abbreviatedTimeZoneDST[e.toUpperCase()]:Date.CultureInfo.abbreviatedTimeZoneStandard[e.toUpperCase()]};Date.getTimezoneAbbreviation=function(e,t){var n=t||false?Date.CultureInfo.abbreviatedTimeZoneDST:Date.CultureInfo.abbreviatedTimeZoneStandard,r;for(r in n){if(n[r]===e){return r}}return null};Date.prototype.clone=function(){return new Date(this.getTime())};Date.prototype.compareTo=function(e){if(isNaN(this)){throw new Error(this)}if(e instanceof Date&&!isNaN(e)){return this>e?1:this<e?-1:0}else{throw new TypeError(e)}};Date.prototype.equals=function(e){return this.compareTo(e)===0};Date.prototype.between=function(e,t){var n=this.getTime();return n>=e.getTime()&&n<=t.getTime()};Date.prototype.addMilliseconds=function(e){this.setMilliseconds(this.getMilliseconds()+e);return 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();this.setDate(1);this.setMonth(this.getMonth()+e);this.setDate(Math.min(t,this.getDaysInMonth()));return this};Date.prototype.addYears=function(e){return this.addMonths(e*12)};Date.prototype.add=function(e){if(typeof e=="number"){this._orient=e;return this}var t=e;if(t.millisecond||t.milliseconds){this.addMilliseconds(t.millisecond||t.milliseconds)}if(t.second||t.seconds){this.addSeconds(t.second||t.seconds)}if(t.minute||t.minutes){this.addMinutes(t.minute||t.minutes)}if(t.hour||t.hours){this.addHours(t.hour||t.hours)}if(t.month||t.months){this.addMonths(t.month||t.months)}if(t.year||t.years){this.addYears(t.year||t.years)}if(t.day||t.days){this.addDays(t.day||t.days)}return this};Date._validate=function(e,t,n,r){if(typeof e!="number"){throw new TypeError(e+" is not a Number.")}else if(e<t||e>n){throw new RangeError(e+" is not a valid value for "+r+".")}return true};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;if(!t.millisecond&&t.millisecond!==0){t.millisecond=-1}if(!t.second&&t.second!==0){t.second=-1}if(!t.minute&&t.minute!==0){t.minute=-1}if(!t.hour&&t.hour!==0){t.hour=-1}if(!t.day&&t.day!==0){t.day=-1}if(!t.month&&t.month!==0){t.month=-1}if(!t.year&&t.year!==0){t.year=-1}if(t.millisecond!=-1&&Date.validateMillisecond(t.millisecond)){this.addMilliseconds(t.millisecond-this.getMilliseconds())}if(t.second!=-1&&Date.validateSecond(t.second)){this.addSeconds(t.second-this.getSeconds())}if(t.minute!=-1&&Date.validateMinute(t.minute)){this.addMinutes(t.minute-this.getMinutes())}if(t.hour!=-1&&Date.validateHour(t.hour)){this.addHours(t.hour-this.getHours())}if(t.month!==-1&&Date.validateMonth(t.month)){this.addMonths(t.month-this.getMonth())}if(t.year!=-1&&Date.validateYear(t.year)){this.addYears(t.year-this.getFullYear())}if(t.day!=-1&&Date.validateDay(t.day,this.getFullYear(),this.getMonth())){this.addDays(t.day-this.getDate())}if(t.timezone){this.setTimezone(t.timezone)}if(t.timezoneOffset){this.setTimezoneOffset(t.timezoneOffset)}return this};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return 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.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){var t=this.getFullYear(),n=this.getMonth(),r=this.getDate();var i=e||Date.CultureInfo.firstDayOfWeek;var s=7+1-(new Date(t,0,1)).getDay();if(s==8){s=1}var o=(Date.UTC(t,n,r,0,0,0)-Date.UTC(t,0,1,0,0,0))/864e5+1;var u=Math.floor((o-s+7)/7);if(u===i){t--;var a=7+1-(new Date(t,0,1)).getDay();if(a==2||a==8){u=53}else{u=52}}return u};Date.prototype.isDST=function(){console.log("isDST");return 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;this.addMinutes(n-t);return this};Date.prototype.setTimezone=function(e){return this.setTimezoneOffset(Date.getTimezoneOffset(e))};Date.prototype.getUTCOffset=function(){var e=this.getTimezoneOffset()*-10/6,t;if(e<0){t=(e-1e4).toString();return t[0]+t.substr(2)}else{t=(e+1e4).toString();return"+"+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;var 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(true);case"dd":return n(t.getDate());case"d":return t.getDate().toString();case"MMMM":return t.getMonthName();case"MMM":return t.getMonthName(true);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(){this._orient=+1;return this};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var e={};e[this._dateElement]=this;return Date.now().add(e)};Number.prototype.ago=function(){var e={};e[this._dateElement]=this*-1;return Date.now().add(e)};(function(){var e=Date.prototype,t=Number.prototype;var 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;var o=function(e){return function(){if(this._is){this._is=false;return this.getDay()==e}return this.moveToDayOfWeek(e,this._orient)}};for(var u=0;u<n.length;u++){e[n[u]]=e[n[u].substring(0,3)]=o(u)}var a=function(e){return function(){if(this._is){this._is=false;return this.getMonth()===e}return this.moveToMonth(e,this._orient)}};for(var f=0;f<r.length;f++){e[r[f]]=e[r[f].substring(0,3)]=a(f)}var l=function(e){return function(){if(e.substring(e.length-1)!="s"){e+="s"}return this["add"+e](this._orient)}};var c=function(e){return function(){this._dateElement=e;return this}};for(var h=0;h<i.length;h++){s=i[h].toLowerCase();e[s]=e[s+"s"]=l(i[h]);t[s]=t[s+"s"]=c(s)}})();Date.prototype.toJSONString=function(){return this.toString("yyyy-MM-ddThh:mm:ssZ")};Date.prototype.toShortDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern)};Date.prototype.toLongDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.longDatePattern)};Date.prototype.toShortTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortTimePattern)};Date.prototype.toLongTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.longTimePattern)};Date.prototype.getOrdinal=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}};(function(){Date.Parsing={Exception:function(e){this.message="Parse error at '"+e.substring(0,10)+" ...'"}};var e=Date.Parsing;var t=e.Operators={rtoken:function(t){return function(n){var i=n.match(t);if(i){return[i[0],n.substring(i[0].length)]}else{throw new e.Exception(n)}}},token:function(e){return function(e){return t.rtoken(new RegExp("^s*"+e+"s*"))(e)}},stoken:function(e){return t.rtoken(new RegExp("^"+e))},until:function(e){return function(t){var n=[],r=null;while(t.length){try{r=e.call(this,t)}catch(i){n.push(r[0]);t=r[1];continue}break}return[n,t]}},many:function(e){return function(t){var n=[],r=null;while(t.length){try{r=e.call(this,t)}catch(i){return[n,t]}n.push(r[0]);t=r[1]}return[n,t]}},optional:function(e){return function(t){var n=null;try{n=e.call(this,t)}catch(r){return[null,t]}return[n[0],n[1]]}},not:function(t){return function(n){try{t.call(this,n)}catch(r){return[null,n]}throw new e.Exception(n)}},ignore:function(e){return e?function(t){var n=null;n=e.call(this,t);return[null,n[1]]}:null},product:function(){var e=arguments[0],n=Array.prototype.slice.call(arguments,1),r=[];for(var i=0;i<e.length;i++){r.push(t.each(e[i],n))}return r},cache:function(t){var n={},r=null;return function(i){try{r=n[i]=n[i]||t.call(this,i)}catch(s){r=n[i]=s}if(r instanceof e.Exception){throw r}else{return r}}},any:function(){var t=arguments;return function(n){var r=null;for(var i=0;i<t.length;i++){if(t[i]==null){continue}try{r=t[i].call(this,n)}catch(s){r=null}if(r){return r}}throw new e.Exception(n)}},each:function(){var t=arguments;return function(n){var r=[],i=null;for(var s=0;s<t.length;s++){if(t[s]==null){continue}try{i=t[s].call(this,n)}catch(o){throw new e.Exception(n)}r.push(i[0]);n=i[1]}return[r,n]}},all:function(){var e=arguments,t=t;return t.each(t.optional(e))},sequence:function(n,r,i){r=r||t.rtoken(/^\s*/);i=i||null;if(n.length==1){return n[0]}return function(t){var s=null,o=null;var u=[];for(var a=0;a<n.length;a++){try{s=n[a].call(this,t)}catch(f){break}u.push(s[0]);try{o=r.call(this,s[1])}catch(l){o=null;break}t=o[1]}if(!s){throw new e.Exception(t)}if(o){throw new e.Exception(o[1])}if(i){try{s=i.call(this,s[1])}catch(h){throw new e.Exception(s[1])}}return[u,s?s[1]:t]}},between:function(e,n,i){i=i||e;var s=t.each(t.ignore(e),n,t.ignore(i));return function(e){var t=s.call(this,e);return[[t[0][0],r[0][2]],t[1]]}},list:function(e,n,r){n=n||t.rtoken(/^\s*/);r=r||null;return e instanceof Array?t.each(t.product(e.slice(0,-1),t.ignore(n)),e.slice(-1),t.ignore(r)):t.each(t.many(t.each(e,t.ignore(n))),px,t.ignore(r))},set:function(n,r,i){r=r||t.rtoken(/^\s*/);i=i||null;return function(s){var o=null,u=null,a=null,f=null,l=[[],s],h=false;for(var p=0;p<n.length;p++){a=null;u=null;o=null;h=n.length==1;try{o=n[p].call(this,s)}catch(v){continue}f=[[o[0]],o[1]];if(o[1].length>0&&!h){try{a=r.call(this,o[1])}catch(m){h=true}}else{h=true}if(!h&&a[1].length===0){h=true}if(!h){var g=[];for(var y=0;y<n.length;y++){if(p!=y){g.push(n[y])}}u=t.set(g,r).call(this,a[1]);if(u[0].length>0){f[0]=f[0].concat(u[0]);f[1]=u[1]}}if(f[1].length<l[1].length){l=f}if(l[1].length===0){break}}if(l[0].length===0){return l}if(i){try{a=i.call(this,l[1])}catch(b){throw new e.Exception(l[1])}l[1]=a[1]}return l}},forward:function(e,t){return function(n){return e[t].call(this,n)}},replace:function(e,t){return function(n){var r=e.call(this,n);return[t,r[1]]}},process:function(e,t){return function(n){var r=e.call(this,n);return[t.call(this,r[0]),r[1]]}},min:function(t,n){return function(r){var i=n.call(this,r);if(i[0].length<t){throw new e.Exception(r)}return i}}};var n=function(e){return function(){var t=null,n=[];if(arguments.length>1){t=Array.prototype.slice.call(arguments)}else if(arguments[0]instanceof Array){t=arguments[0]}if(t){for(var r=0,i=t.shift();r<i.length;r++){t.unshift(i[r]);n.push(e.apply(null,t));t.shift();return n}}else{return e.apply(null,arguments)}}};var i="optional not ignore cache".split(/\s/);for(var s=0;s<i.length;s++){t[i[s]]=n(t[i[s]])}var o=function(e){return function(){if(arguments[0]instanceof Array){return e.apply(null,arguments[0])}else{return e.apply(null,arguments)}}};var u="each any all".split(/\s/);for(var a=0;a<u.length;a++){t[u[a]]=o(t[u[a]])}})();(function(){var e=function(t){var n=[];for(var r=0;r<t.length;r++){if(t[r]instanceof Array){n=n.concat(e(t[r]))}else{if(t[r]){n.push(t[r])}}}return n};Date.Grammar={};Date.Translator={hour:function(e){return function(){this.hour=Number(e)}},minute:function(e){return function(){this.minute=Number(e)}},second:function(e){return function(){this.second=Number(e)}},meridian:function(e){return function(){this.meridian=e.slice(0,1).toLowerCase()}},timezone:function(e){return function(){var t=e.replace(/[^\d\+\-]/g,"");if(t.length){this.timezoneOffset=Number(t)}else{this.timezone=e.toLowerCase()}}},day:function(e){var t=e[0];return function(){this.day=Number(t.match(/\d+/)[0])}},month:function(e){return function(){this.month=e.length==3?Date.getMonthNumberFromName(e):Number(e)-1}},year:function(e){return function(){var t=Number(e);this.year=e.length>2?t:t+(t+2e3<Date.CultureInfo.twoDigitYearMax?2e3:1900)}},rday:function(e){return function(){switch(e){case"yesterday":this.days=-1;break;case"tomorrow":this.days=1;break;case"today":this.days=0;break;case"now":this.days=0;this.now=true;break}}},finishExact:function(e){e=e instanceof Array?e:[e];var t=new Date;this.year=t.getFullYear();this.month=t.getMonth();this.day=1;this.hour=0;this.minute=0;this.second=0;for(var n=0;n<e.length;n++){if(e[n]){e[n].call(this)}}this.hour=this.meridian=="p"&&this.hour<13?this.hour+12:this.hour;if(this.day>Date.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);if(this.timezone){r.set({timezone:this.timezone})}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset})}return r},finish:function(t){t=t instanceof Array?e(t):[t];if(t.length===0){return null}for(var n=0;n<t.length;n++){if(typeof t[n]=="function"){t[n].call(this)}}if(this.now){return new Date}var r=Date.today();var i=null;var s=!!(this.days!=null||this.orient||this.operator);if(s){var o,u,a;a=this.orient=="past"||this.operator=="subtract"?-1:1;if(this.weekday){this.unit="day";o=Date.getDayNumberFromName(this.weekday)-r.getDay();u=7;this.days=o?(o+a*u)%u:a*u}if(this.month){this.unit="month";o=this.month-r.getMonth();u=12;this.months=o?(o+a*u)%u:a*u;this.month=null}if(!this.unit){this.unit="day"}if(this[this.unit+"s"]==null||this.operator!=null){if(!this.value){this.value=1}if(this.unit=="week"){this.unit="day";this.value=this.value*7}this[this.unit+"s"]=this.value*a}return r.add(this)}else{if(this.meridian&&this.hour){this.hour=this.hour<13&&this.meridian=="p"?this.hour+12:this.hour}if(this.weekday&&!this.day){this.day=r.addDays(Date.getDayNumberFromName(this.weekday)-r.getDay()).getDate()}if(this.month&&!this.day){this.day=1}return r.set(this)}}};var t=Date.Parsing.Operators,n=Date.Grammar,r=Date.Translator,i;n.datePartDelimiter=t.rtoken(/^([\s\-\.\,\/\x27]+)/);n.timePartDelimiter=t.stoken(":");n.whiteSpace=t.rtoken(/^\s*/);n.generalDelimiter=t.rtoken(/^(([\s\,]|at|on)+)/);var s={};n.ctoken=function(e){var n=s[e];if(!n){var r=Date.CultureInfo.regexPatterns;var i=e.split(/\s+/),o=[];for(var u=0;u<i.length;u++){o.push(t.replace(t.rtoken(r[i[u]]),i[u]))}n=s[e]=t.any.apply(null,o)}return n};n.ctoken2=function(e){return t.rtoken(Date.CultureInfo.regexPatterns[e])};n.h=t.cache(t.process(t.rtoken(/^(0[0-9]|1[0-2]|[1-9])/),r.hour));n.hh=t.cache(t.process(t.rtoken(/^(0[0-9]|1[0-2])/),r.hour));n.H=t.cache(t.process(t.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/),r.hour));n.HH=t.cache(t.process(t.rtoken(/^([0-1][0-9]|2[0-3])/),r.hour));n.m=t.cache(t.process(t.rtoken(/^([0-5][0-9]|[0-9])/),r.minute));n.mm=t.cache(t.process(t.rtoken(/^[0-5][0-9]/),r.minute));n.s=t.cache(t.process(t.rtoken(/^([0-5][0-9]|[0-9])/),r.second));n.ss=t.cache(t.process(t.rtoken(/^[0-5][0-9]/),r.second));n.hms=t.cache(t.sequence([n.H,n.mm,n.ss],n.timePartDelimiter));n.t=t.cache(t.process(n.ctoken2("shortMeridian"),r.meridian));n.tt=t.cache(t.process(n.ctoken2("longMeridian"),r.meridian));n.z=t.cache(t.process(t.rtoken(/^(\+|\-)?\s*\d\d\d\d?/),r.timezone));n.zz=t.cache(t.process(t.rtoken(/^(\+|\-)\s*\d\d\d\d/),r.timezone));n.zzz=t.cache(t.process(n.ctoken2("timezone"),r.timezone));n.timeSuffix=t.each(t.ignore(n.whiteSpace),t.set([n.tt,n.zzz]));n.time=t.each(t.optional(t.ignore(t.stoken("T"))),n.hms,n.timeSuffix);n.d=t.cache(t.process(t.each(t.rtoken(/^([0-2]\d|3[0-1]|\d)/),t.optional(n.ctoken2("ordinalSuffix"))),r.day));n.dd=t.cache(t.process(t.each(t.rtoken(/^([0-2]\d|3[0-1])/),t.optional(n.ctoken2("ordinalSuffix"))),r.day));n.ddd=n.dddd=t.cache(t.process(n.ctoken("sun mon tue wed thu fri sat"),function(e){return function(){this.weekday=e}}));n.M=t.cache(t.process(t.rtoken(/^(1[0-2]|0\d|\d)/),r.month));n.MM=t.cache(t.process(t.rtoken(/^(1[0-2]|0\d)/),r.month));n.MMM=n.MMMM=t.cache(t.process(n.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"),r.month));n.y=t.cache(t.process(t.rtoken(/^(\d\d?)/),r.year));n.yy=t.cache(t.process(t.rtoken(/^(\d\d)/),r.year));n.yyy=t.cache(t.process(t.rtoken(/^(\d\d?\d?\d?)/),r.year));n.yyyy=t.cache(t.process(t.rtoken(/^(\d\d\d\d)/),r.year));i=function(){return t.each(t.any.apply(null,arguments),t.not(n.ctoken2("timeContext")))};n.day=i(n.d,n.dd);n.month=i(n.M,n.MMM);n.year=i(n.yyyy,n.yy);n.orientation=t.process(n.ctoken("past future"),function(e){return function(){this.orient=e}});n.operator=t.process(n.ctoken("add subtract"),function(e){return function(){this.operator=e}});n.rday=t.process(n.ctoken("yesterday tomorrow today now"),r.rday);n.unit=t.process(n.ctoken("minute hour day week month year"),function(e){return function(){this.unit=e}});n.value=t.process(t.rtoken(/^\d\d?(st|nd|rd|th)?/),function(e){return function(){this.value=e.replace(/\D/g,"")}});n.expression=t.set([n.rday,n.operator,n.value,n.unit,n.orientation,n.ddd,n.MMM]);i=function(){return t.set(arguments,n.datePartDelimiter)};n.mdy=i(n.ddd,n.month,n.day,n.year);n.ymd=i(n.ddd,n.year,n.month,n.day);n.dmy=i(n.ddd,n.day,n.month,n.year);n.date=function(e){return(n[Date.CultureInfo.dateElementOrder]||n.mdy).call(this,e)};n.format=t.process(t.many(t.any(t.process(t.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),function(e){if(n[e]){return n[e]}else{throw Date.Parsing.Exception(e)}}),t.process(t.rtoken(/^[^dMyhHmstz]+/),function(e){return t.ignore(t.stoken(e))}))),function(e){return t.process(t.each.apply(null,e),r.finishExact)});var o={};var u=function(e){return o[e]=o[e]||n.format(e)[0]};n.formats=function(e){if(e instanceof Array){var n=[];for(var r=0;r<e.length;r++){n.push(u(e[r]))}return t.any.apply(null,n)}else{return u(e)}};n._formats=n.formats(["yyyy-MM-ddTHH:mm:ss","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","d"]);n._start=t.process(t.set([n.date,n.time,n.expression],n.generalDelimiter,n.whiteSpace),r.finish);n.start=function(e){try{var t=n._formats.call({},e);if(t[1].length===0){return t}}catch(r){}return n._start.call({},e)}})();Date._parse=Date.parse;Date.parse=function(e){var t=null;if(!e){return null}try{t=Date.Grammar.start.call({},e)}catch(n){return null}return t[1].length===0?t[0]:null};Date.getParseFunction=function(e){var t=Date.Grammar.formats(e);return function(e){var n=null;try{n=t.call({},e)}catch(r){return null}return n[1].length===0?n[0]:null}};Date.parseExact=function(e,t){return Date.getParseFunction(t)(e)};
