-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.min.js
8 lines (8 loc) · 27.1 KB
/
date.min.js
1
2
3
4
5
6
7
8
/**
* @version: 1.0 Alpha-1
* @author: Coolite Inc. http://www.coolite.com/
* @date: 2008-05-13
* @copyright: Copyright (c) 2006-2008, 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/
*/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:/^(\+|aft(er)?|from|hence)/i,subtract:/^(\-|bef(ore)?|ago)/i,yesterday:/^yes(terday)?/i,today:/^t(od(ay)?)?/i,tomorrow:/^tom(orrow)?/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^mn|min(ute)?s?/i,hour:/^h(our)?s?/i,week:/^w(eek)?s?/i,month:/^m(onth)?s?/i,day:/^d(ay)?s?/i,year:/^y(ear)?s?/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|utc)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a(?!u|p)|p)/i},timezones:[{name:"UTC",offset:"-000"},{name:"GMT",offset:"-000"},{name:"EST",offset:"-0500"},{name:"EDT",offset:"-0400"},{name:"CST",offset:"-0600"},{name:"CDT",offset:"-0500"},{name:"MST",offset:"-0700"},{name:"MDT",offset:"-0600"},{name:"PST",offset:"-0800"},{name:"PDT",offset:"-0700"}]};(function(){var e=Date,t=e.prototype,n=e.CultureInfo,r=function(e,t){t||(t=2);return("000"+e).slice(t*-1)};t.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this};t.setTimeToNow=function(){var e=new Date;this.setHours(e.getHours());this.setMinutes(e.getMinutes());this.setSeconds(e.getSeconds());this.setMilliseconds(e.getMilliseconds());return this};e.today=function(){return(new Date).clearTime()};e.compare=function(e,t){if(isNaN(e)||isNaN(t))throw new Error(e+" - "+t);if(e instanceof Date&&t instanceof Date)return e<t?-1:e>t?1:0;throw new TypeError(e+" - "+t)};e.equals=function(e,t){return e.compareTo(t)===0};e.getDayNumberFromName=function(e){var t=n.dayNames,r=n.abbreviatedDayNames,i=n.shortestDayNames,s=e.toLowerCase();for(var o=0;o<t.length;o++)if(t[o].toLowerCase()==s||r[o].toLowerCase()==s||i[o].toLowerCase()==s)return o;return-1};e.getMonthNumberFromName=function(e){var t=n.monthNames,r=n.abbreviatedMonthNames,i=e.toLowerCase();for(var s=0;s<t.length;s++)if(t[s].toLowerCase()==i||r[s].toLowerCase()==i)return s;return-1};e.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0};e.getDaysInMonth=function(t,n){return[31,e.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][n]};e.getTimezoneAbbreviation=function(e){var t=n.timezones,r;for(var i=0;i<t.length;i++)if(t[i].offset===e)return t[i].name;return null};e.getTimezoneOffset=function(e){var t=n.timezones,r;for(var i=0;i<t.length;i++)if(t[i].name===e.toUpperCase())return t[i].offset;return null};t.clone=function(){return new Date(this.getTime())};t.compareTo=function(e){return Date.compare(this,e)};t.equals=function(e){return Date.equals(this,e||new Date)};t.between=function(e,t){return this.getTime()>=e.getTime()&&this.getTime()<=t.getTime()};t.isAfter=function(e){return this.compareTo(e||new Date)===1};t.isBefore=function(e){return this.compareTo(e||new Date)===-1};t.isToday=function(){return this.isSameDay(new Date)};t.isSameDay=function(e){return this.clone().clearTime().equals(e.clone().clearTime())};t.addMilliseconds=function(e){this.setMilliseconds(this.getMilliseconds()+e);return this};t.addSeconds=function(e){return this.addMilliseconds(e*1e3)};t.addMinutes=function(e){return this.addMilliseconds(e*6e4)};t.addHours=function(e){return this.addMilliseconds(e*36e5)};t.addDays=function(e){this.setDate(this.getDate()+e);return this};t.addWeeks=function(e){return this.addDays(e*7)};t.addMonths=function(t){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+t);this.setDate(Math.min(n,e.getDaysInMonth(this.getFullYear(),this.getMonth())));return this};t.addYears=function(e){return this.addMonths(e*12)};t.add=function(e){if(typeof e=="number"){this._orient=e;return this}var t=e;t.milliseconds&&this.addMilliseconds(t.milliseconds);t.seconds&&this.addSeconds(t.seconds);t.minutes&&this.addMinutes(t.minutes);t.hours&&this.addHours(t.hours);t.weeks&&this.addWeeks(t.weeks);t.months&&this.addMonths(t.months);t.years&&this.addYears(t.years);t.days&&this.addDays(t.days);return this};var i,s,o;t.getWeek=function(){var e,t,n,r,u,a,f,l,c,h;i=i?i:this.getFullYear();s=s?s:this.getMonth()+1;o=o?o:this.getDate();if(s<=2){e=i-1;t=(e/4|0)-(e/100|0)+(e/400|0);n=((e-1)/4|0)-((e-1)/100|0)+((e-1)/400|0);c=t-n;u=0;a=o-1+31*(s-1)}else{e=i;t=(e/4|0)-(e/100|0)+(e/400|0);n=((e-1)/4|0)-((e-1)/100|0)+((e-1)/400|0);c=t-n;u=c+1;a=o+(153*(s-3)+2)/5+58+c}f=(e+t)%7;r=(a+f-u)%7;l=a+3-r|0;l<0?h=53-((f-c)/5|0):l>364+c?h=1:h=(l/7|0)+1;i=s=o=null;return h};t.getISOWeek=function(){i=this.getUTCFullYear();s=this.getUTCMonth()+1;o=this.getUTCDate();return r(this.getWeek())};t.setWeek=function(e){return this.moveToDayOfWeek(1).addWeeks(e-this.getWeek())};e._validate=function(e,t,n,r){if(typeof e=="undefined")return!1;if(typeof e!="number")throw new TypeError(e+" is not a Number.");if(e<t||e>n)throw new RangeError(e+" is not a valid value for "+r+".");return!0};e.validateMillisecond=function(t){return e._validate(t,0,999,"millisecond")};e.validateSecond=function(t){return e._validate(t,0,59,"second")};e.validateMinute=function(t){return e._validate(t,0,59,"minute")};e.validateHour=function(t){return e._validate(t,0,23,"hour")};e.validateDay=function(t,n,r){return e._validate(t,1,e.getDaysInMonth(n,r),"day")};e.validateMonth=function(t){return e._validate(t,0,11,"month")};e.validateYear=function(t){return e._validate(t,0,9999,"year")};t.set=function(t){e.validateMillisecond(t.millisecond)&&this.addMilliseconds(t.millisecond-this.getMilliseconds());e.validateSecond(t.second)&&this.addSeconds(t.second-this.getSeconds());e.validateMinute(t.minute)&&this.addMinutes(t.minute-this.getMinutes());e.validateHour(t.hour)&&this.addHours(t.hour-this.getHours());e.validateMonth(t.month)&&this.addMonths(t.month-this.getMonth());e.validateYear(t.year)&&this.addYears(t.year-this.getFullYear());e.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);t.week&&e._validate(t.week,0,53,"week")&&this.setWeek(t.week);return this};t.moveToFirstDayOfMonth=function(){return this.set({day:1})};t.moveToLastDayOfMonth=function(){return this.set({day:e.getDaysInMonth(this.getFullYear(),this.getMonth())})};t.moveToNthOccurrence=function(e,t){var n=0;if(t>0)n=t-1;else if(t===-1){this.moveToLastDayOfMonth();this.getDay()!==e&&this.moveToDayOfWeek(e,-1);return this}return this.moveToFirstDayOfMonth().addDays(-1).moveToDayOfWeek(e,1).addWeeks(n)};t.moveToDayOfWeek=function(e,t){var n=(e-this.getDay()+7*(t||1))%7;return this.addDays(n===0?n+=7*(t||1):n)};t.moveToMonth=function(e,t){var n=(e-this.getMonth()+12*(t||1))%12;return this.addMonths(n===0?n+=12*(t||1):n)};t.getOrdinalNumber=function(){return Math.ceil((this.clone().clearTime()-new Date(this.getFullYear(),0,1))/864e5)+1};t.getTimezone=function(){return e.getTimezoneAbbreviation(this.getUTCOffset())};t.setTimezoneOffset=function(e){var t=this.getTimezoneOffset(),n=Number(e)*-6/10;return this.addMinutes(n-t)};t.setTimezone=function(t){return this.setTimezoneOffset(e.getTimezoneOffset(t))};t.hasDaylightSavingTime=function(){return Date.today().set({month:0,day:1}).getTimezoneOffset()!==Date.today().set({month:6,day:1}).getTimezoneOffset()};t.isDaylightSavingTime=function(){return this.hasDaylightSavingTime()&&(new Date).getTimezoneOffset()===Date.today().set({month:6,day:1}).getTimezoneOffset()};t.getUTCOffset=function(){var e=this.getTimezoneOffset()*-10/6,t;if(e<0){t=(e-1e4).toString();return t.charAt(0)+t.substr(2)}t=(e+1e4).toString();return"+"+t.substr(1)};t.getElapsed=function(e){return(e||new Date)-this};t.toISOString||(t.toISOString=function(){function e(e){return e<10?"0"+e:e}return'"'+this.getUTCFullYear()+"-"+e(this.getUTCMonth()+1)+"-"+e(this.getUTCDate())+"T"+e(this.getUTCHours())+":"+e(this.getUTCMinutes())+":"+e(this.getUTCSeconds())+'Z"'});t._toString=t.toString;t.toString=function(e){var t=this;if(e&&e.length==1){var i=n.formatPatterns;t.t=t.toString;switch(e){case"d":return t.t(i.shortDate);case"D":return t.t(i.longDate);case"F":return t.t(i.fullDateTime);case"m":return t.t(i.monthDay);case"r":return t.t(i.rfc1123);case"s":return t.t(i.sortableDateTime);case"t":return t.t(i.shortTime);case"T":return t.t(i.longTime);case"u":return t.t(i.universalSortableDateTime);case"y":return t.t(i.yearMonth)}}var s=function(e){switch(e*1){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}};return e?e.replace(/(\\)?(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)/g,function(e){if(e.charAt(0)==="\\")return e.replace("\\","");t.h=t.getHours;switch(e){case"hh":return r(t.h()<13?t.h()===0?12:t.h():t.h()-12);case"h":return t.h()<13?t.h()===0?12:t.h():t.h()-12;case"HH":return r(t.h());case"H":return t.h();case"mm":return r(t.getMinutes());case"m":return t.getMinutes();case"ss":return r(t.getSeconds());case"s":return t.getSeconds();case"yyyy":return r(t.getFullYear(),4);case"yy":return r(t.getFullYear());case"dddd":return n.dayNames[t.getDay()];case"ddd":return n.abbreviatedDayNames[t.getDay()];case"dd":return r(t.getDate());case"d":return t.getDate();case"MMMM":return n.monthNames[t.getMonth()];case"MMM":return n.abbreviatedMonthNames[t.getMonth()];case"MM":return r(t.getMonth()+1);case"M":return t.getMonth()+1;case"t":return t.h()<12?n.amDesignator.substring(0,1):n.pmDesignator.substring(0,1);case"tt":return t.h()<12?n.amDesignator:n.pmDesignator;case"S":return s(t.getDate());default:return e}}):this._toString()}})();(function(){var e=Date,t=e.prototype,n=e.CultureInfo,r=Number.prototype;t._orient=1;t._nth=null;t._is=!1;t._same=!1;t._isSecond=!1;r._dateElement="day";t.next=function(){this._orient=1;return this};e.next=function(){return e.today().next()};t.last=t.prev=t.previous=function(){this._orient=-1;return this};e.last=e.prev=e.previous=function(){return e.today().last()};t.is=function(){this._is=!0;return this};t.same=function(){this._same=!0;this._isSecond=!1;return this};t.today=function(){return this.same().day()};t.weekday=function(){if(this._is){this._is=!1;return!this.is().sat()&&!this.is().sun()}return!1};t.at=function(t){return typeof t=="string"?e.parse(this.toString("d")+" "+t):this.set(t)};r.fromNow=r.after=function(e){var t={};t[this._dateElement]=this;return(e?e.clone():new Date).add(t)};r.ago=r.before=function(e){var t={};t[this._dateElement]=this*-1;return(e?e.clone():new Date).add(t)};var i="sunday monday tuesday wednesday thursday friday saturday".split(/\s/),s="january february march april may june july august september october november december".split(/\s/),o="Millisecond Second Minute Hour Day Week Month Year".split(/\s/),u="Milliseconds Seconds Minutes Hours Date Week Month FullYear".split(/\s/),a="final first second third fourth fifth".split(/\s/),f;t.toObject=function(){var e={};for(var t=0;t<o.length;t++)e[o[t].toLowerCase()]=this["get"+u[t]]();return e};e.fromObject=function(e){e.week=null;return Date.today().set(e)};var l=function(t){return function(){if(this._is){this._is=!1;return this.getDay()==t}if(this._nth!==null){this._isSecond&&this.addSeconds(this._orient*-1);this._isSecond=!1;var n=this._nth;this._nth=null;var r=this.clone().moveToLastDayOfMonth();this.moveToNthOccurrence(t,n);if(this>r)throw new RangeError(e.getDayName(t)+" does not occur "+n+" times in the month of "+e.getMonthName(r.getMonth())+" "+r.getFullYear()+".");return this}return this.moveToDayOfWeek(t,this._orient)}},c=function(t){return function(){var r=e.today(),i=t-r.getDay();t===0&&n.firstDayOfWeek===1&&r.getDay()!==0&&(i+=7);return r.addDays(i)}};for(var h=0;h<i.length;h++){e[i[h].toUpperCase()]=e[i[h].toUpperCase().substring(0,3)]=h;e[i[h]]=e[i[h].substring(0,3)]=c(h);t[i[h]]=t[i[h].substring(0,3)]=l(h)}var p=function(e){return function(){if(this._is){this._is=!1;return this.getMonth()===e}return this.moveToMonth(e,this._orient)}},d=function(t){return function(){return e.today().set({month:t,day:1})}};for(var v=0;v<s.length;v++){e[s[v].toUpperCase()]=e[s[v].toUpperCase().substring(0,3)]=v;e[s[v]]=e[s[v].substring(0,3)]=d(v);t[s[v]]=t[s[v].substring(0,3)]=p(v)}var m=function(e){return function(){if(this._isSecond){this._isSecond=!1;return this}if(this._same){this._same=this._is=!1;var t=this.toObject(),n=(arguments[0]||new Date).toObject(),r="",i=e.toLowerCase();for(var s=o.length-1;s>-1;s--){r=o[s].toLowerCase();if(t[r]!=n[r])return!1;if(i==r)break}return!0}e.substring(e.length-1)!="s"&&(e+="s");return this["add"+e](this._orient)}},g=function(e){return function(){this._dateElement=e;return this}};for(var y=0;y<o.length;y++){f=o[y].toLowerCase();t[f]=t[f+"s"]=m(o[y]);r[f]=r[f+"s"]=g(f)}t._ss=m("Second");var b=function(e){return function(t){if(this._same)return this._ss(arguments[0]);if(t||t===0)return this.moveToNthOccurrence(t,e);this._nth=e;if(e!==2||t!==undefined&&t!==null)return this;this._isSecond=!0;return this.addSeconds(this._orient)}};for(var w=0;w<a.length;w++)t[a[w]]=w===0?b(-1):b(w)})();(function(){Date.Parsing={Exception:function(e){this.message="Parse error at '"+e.substring(0,10)+" ...'"}};var e=Date.Parsing,t=e.Operators={rtoken:function(t){return function(n){var i=n.match(t);if(i)return[i[0],n.substring(i[0].length)];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;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;return n.length==1?n[0]:function(t){var s=null,o=null,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=!1;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=!0}else h=!0;!h&&a[1].length===0&&(h=!0);if(!h){var g=[];for(var y=0;y<n.length;y++)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]}}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}}},n=function(e){return function(){var t=null,n=[];arguments.length>1?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();r<i.length;r++){t.unshift(i[r]);n.push(e.apply(null,t));t.shift();return n}}},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(){return arguments[0]instanceof Array?e.apply(null,arguments[0]):e.apply(null,arguments)}},u="each any all".split(/\s/);for(var a=0;a<u.length;a++)t[u[a]]=o(t[u[a]])})();(function(){var e=Date,t=e.prototype,n=e.CultureInfo,r=function(e){var t=[];for(var n=0;n<e.length;n++)e[n]instanceof Array?t=t.concat(r(e[n])):e[n]&&t.push(e[n]);return t};e.Grammar={};e.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,"");t.length?this.timezoneOffset=Number(t):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?"jan feb mar apr may jun jul aug sep oct nov dec".indexOf(e)/4:Number(e)-1}},year:function(e){return function(){var t=Number(e);this.year=e.length>2?t:t+(t+2e3<n.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=!0}}},finishExact:function(t){t=t instanceof Array?t:[t];for(var n=0;n<t.length;n++)t[n]&&t[n].call(this);var r=new Date;(this.hour||this.minute)&&!this.month&&!this.year&&!this.day&&(this.day=r.getDate());this.year||(this.year=r.getFullYear());!this.month&&this.month!==0&&(this.month=r.getMonth());this.day||(this.day=1);this.hour||(this.hour=0);this.minute||(this.minute=0);this.second||(this.second=0);this.meridian&&this.hour&&(this.meridian=="p"&&this.hour<12?this.hour=this.hour+12:this.meridian=="a"&&this.hour==12&&(this.hour=0));if(this.day>e.getDaysInMonth(this.year,this.month))throw new RangeError(this.day+" is not a valid value for days.");var i=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);this.timezone?i.set({timezone:this.timezone}):this.timezoneOffset&&i.set({timezoneOffset:this.timezoneOffset});return i},finish:function(t){t=t instanceof Array?r(t):[t];if(t.length===0)return null;for(var n=0;n<t.length;n++)typeof t[n]=="function"&&t[n].call(this);var i=e.today();if(this.now&&!this.unit&&!this.operator)return new Date;this.now&&(i=new Date);var s=!!(this.days&&this.days!==null||this.orient||this.operator),o,u,a;a=this.orient=="past"||this.operator=="subtract"?-1:1;!this.now&&"hour minute second".indexOf(this.unit)!=-1&&i.setTimeToNow();if(this.month||this.month===0)if("year day hour minute second".indexOf(this.unit)!=-1){this.value=this.month+1;this.month=null;s=!0}if(!s&&this.weekday&&!this.day&&!this.days){var f=Date[this.weekday]();this.day=f.getDate();this.month||(this.month=f.getMonth());this.year=f.getFullYear()}if(s&&this.weekday&&this.unit!="month"){this.unit="day";o=e.getDayNumberFromName(this.weekday)-i.getDay();u=7;this.days=o?(o+a*u)%u:a*u}if(this.month&&this.unit=="day"&&this.operator){this.value=this.month+1;this.month=null}this.value!=null&&this.month!=null&&this.year!=null&&(this.day=this.value*1);if(this.month&&!this.day&&this.value){i.set({day:this.value*1});s||(this.day=this.value*1)}if(!this.month&&this.value&&this.unit=="month"&&!this.now){this.month=this.value;s=!0}if(s&&(this.month||this.month===0)&&this.unit!="year"){this.unit="month";o=this.month-i.getMonth();u=12;this.months=o?(o+a*u)%u:a*u;this.month=null}this.unit||(this.unit="day");if(!this.value&&this.operator&&this.operator!==null&&this[this.unit+"s"]&&this[this.unit+"s"]!==null)this[this.unit+"s"]=this[this.unit+"s"]+(this.operator=="add"?1:-1)+(this.value||0)*a;else if(this[this.unit+"s"]==null||this.operator!=null){this.value||(this.value=1);this[this.unit+"s"]=this.value*a}this.meridian&&this.hour&&(this.meridian=="p"&&this.hour<12?this.hour=this.hour+12:this.meridian=="a"&&this.hour==12&&(this.hour=0));if(this.weekday&&!this.day&&!this.days){var f=Date[this.weekday]();this.day=f.getDate();f.getMonth()!==i.getMonth()&&(this.month=f.getMonth())}(this.month||this.month===0)&&!this.day&&(this.day=1);if(!this.orient&&!this.operator&&this.unit=="week"&&this.value&&!this.day&&!this.month)return Date.today().setWeek(this.value);s&&this.timezone&&this.day&&this.days&&(this.day=this.days);return s?i.add(this):i.set(this)}};var i=e.Parsing.Operators,s=e.Grammar,o=e.Translator,u;s.datePartDelimiter=i.rtoken(/^([\s\-\.\,\/\x27]+)/);s.timePartDelimiter=i.stoken(":");s.whiteSpace=i.rtoken(/^\s*/);s.generalDelimiter=i.rtoken(/^(([\s\,]|at|@|on)+)/);var a={};s.ctoken=function(e){var t=a[e];if(!t){var r=n.regexPatterns,s=e.split(/\s+/),o=[];for(var u=0;u<s.length;u++)o.push(i.replace(i.rtoken(r[s[u]]),s[u]));t=a[e]=i.any.apply(null,o)}return t};s.ctoken2=function(e){return i.rtoken(n.regexPatterns[e])};s.h=i.cache(i.process(i.rtoken(/^(0[0-9]|1[0-2]|[1-9])/),o.hour));s.hh=i.cache(i.process(i.rtoken(/^(0[0-9]|1[0-2])/),o.hour));s.H=i.cache(i.process(i.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/),o.hour));s.HH=i.cache(i.process(i.rtoken(/^([0-1][0-9]|2[0-3])/),o.hour));s.m=i.cache(i.process(i.rtoken(/^([0-5][0-9]|[0-9])/),o.minute));s.mm=i.cache(i.process(i.rtoken(/^[0-5][0-9]/),o.minute));s.s=i.cache(i.process(i.rtoken(/^([0-5][0-9]|[0-9])/),o.second));s.ss=i.cache(i.process(i.rtoken(/^[0-5][0-9]/),o.second));s.hms=i.cache(i.sequence([s.H,s.m,s.s],s.timePartDelimiter));s.t=i.cache(i.process(s.ctoken2("shortMeridian"),o.meridian));s.tt=i.cache(i.process(s.ctoken2("longMeridian"),o.meridian));s.z=i.cache(i.process(i.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/),o.timezone));s.zz=i.cache(i.process(i.rtoken(/^((\+|\-)\s*\d\d\d\d)|((\+|\-)\d\d\:?\d\d)/),o.timezone));s.zzz=i.cache(i.process(s.ctoken2("timezone"),o.timezone));s.timeSuffix=i.each(i.ignore(s.whiteSpace),i.set([s.tt,s.zzz]));s.time=i.each(i.optional(i.ignore(i.stoken("T"))),s.hms,s.timeSuffix);s.d=i.cache(i.process(i.each(i.rtoken(/^([0-2]\d|3[0-1]|\d)/),i.optional(s.ctoken2("ordinalSuffix"))),o.day));s.dd=i.cache(i.process(i.each(i.rtoken(/^([0-2]\d|3[0-1])/),i.optional(s.ctoken2("ordinalSuffix"))),o.day));s.ddd=s.dddd=i.cache(i.process(s.ctoken("sun mon tue wed thu fri sat"),function(e){return function(){this.weekday=e}}));s.M=i.cache(i.process(i.rtoken(/^(1[0-2]|0\d|\d)/),o.month));s.MM=i.cache(i.process(i.rtoken(/^(1[0-2]|0\d)/),o.month));s.MMM=s.MMMM=i.cache(i.process(s.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"),o.month));s.y=i.cache(i.process(i.rtoken(/^(\d\d?)/),o.year));s.yy=i.cache(i.process(i.rtoken(/^(\d\d)/),o.year));s.yyy=i.cache(i.process(i.rtoken(/^(\d\d?\d?\d?)/),o.year));s.yyyy=i.cache(i.process(i.rtoken(/^(\d\d\d\d)/),o.year));u=function(){return i.each(i.any.apply(null,arguments),i.not(s.ctoken2("timeContext")))};s.day=u(s.d,s.dd);s.month=u(s.M,s.MMM);s.year=u(s.yyyy,s.yy);s.orientation=i.process(s.ctoken("past future"),function(e){return function(){this.orient=e}});s.operator=i.process(s.ctoken("add subtract"),function(e){return function(){this.operator=e}});s.rday=i.process(s.ctoken("yesterday tomorrow today now"),o.rday);s.unit=i.process(s.ctoken("second minute hour day week month year"),function(e){return function(){this.unit=e}});s.value=i.process(i.rtoken(/^\d\d?(st|nd|rd|th)?/),function(e){return function(){this.value=e.replace(/\D/g,"")}});s.expression=i.set([s.rday,s.operator,s.value,s.unit,s.orientation,s.ddd,s.MMM]);u=function(){return i.set(arguments,s.datePartDelimiter)};s.mdy=u(s.ddd,s.month,s.day,s.year);s.ymd=u(s.ddd,s.year,s.month,s.day);s.dmy=u(s.ddd,s.day,s.month,s.year);s.date=function(e){return(s[n.dateElementOrder]||s.mdy).call(this,e)};s.format=i.process(i.many(i.any(i.process(i.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),function(t){if(s[t])return s[t];throw e.Parsing.Exception(t)}),i.process(i.rtoken(/^[^dMyhHmstz]+/),function(e){return i.ignore(i.stoken(e))}))),function(e){return i.process(i.each.apply(null,e),o.finishExact)});var f={},l=function(e){return f[e]=f[e]||s.format(e)[0]};s.formats=function(e){if(e instanceof Array){var t=[];for(var n=0;n<e.length;n++)t.push(l(e[n]));return i.any.apply(null,t)}return l(e)};s._formats=s.formats(['"yyyy-MM-ddTHH:mm:ssZ"',"yyyy-MM-ddTHH:mm:ssZ","yyyy-MM-ddTHH:mm:ssz","yyyy-MM-ddTHH:mm:ss","yyyy-MM-ddTHH:mmZ","yyyy-MM-ddTHH:mmz","yyyy-MM-ddTHH:mm","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","MMddyyyy","ddMMyyyy","Mddyyyy","ddMyyyy","Mdyyyy","dMyyyy","yyyy","Mdyy","dMyy","d"]);s._start=i.process(i.set([s.date,s.time,s.expression],s.generalDelimiter,s.whiteSpace),o.finish);s.start=function(e){try{var t=s._formats.call({},e);if(t[1].length===0)return t}catch(n){}return s._start.call({},e)};e._parse=e.parse;e.parse=function(t){var n=null;if(!t)return null;if(t instanceof Date)return t;try{n=e.Grammar.start.call({},t.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1"))}catch(r){return null}return n[1].length===0?n[0]:null};e.getParseFunction=function(t){var n=e.Grammar.formats(t);return function(e){var t=null;try{t=n.call({},e)}catch(r){return null}return t[1].length===0?t[0]:null}};e.parseExact=function(t,n){return e.getParseFunction(n)(t)}})();