All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tools.parse.0.1.7.source-code.luxon.min.js Maven / Gradle / Ivy

There is a newer version: 0.2.2
Show newest version
var luxon=function(e){"use strict";function r(e,t){for(var n=0;n=r.length)break;a=r[o++]}else{if((o=r.next()).done)break;a=o.value}var u=a;u.literal?n+=u.val:n+=t(u.val)}return n}var We={D:W,DD:J,DDD:Y,DDDD:G,t:$,tt:B,ttt:Q,tttt:X,T:K,TT:ee,TTT:te,TTTT:ne,f:re,ff:oe,fff:ue,ffff:ce,F:ie,FF:ae,FFF:se,FFFF:le},Je=function(){function f(e,t){this.opts=t,this.loc=e,this.systemLoc=null}f.create=function(e,t){return void 0===t&&(t={}),new f(e,t)},f.parseFormat=function(e){for(var t=null,n="",r=!1,i=[],o=0;oGt.indexOf(c)&&Qt(this.matrix,a,h,i,c)}else D(a[c])&&(o[c]=a[c])}for(var m in o)0!==o[m]&&(i[r]+=m===r?o[m]:o[m]/this.matrix[r][m]);return Bt(this,{values:i},!0)},e.negate=function(){if(!this.isValid)return this;for(var e={},t=0,n=Object.keys(this.values);te},e.isBefore=function(e){return!!this.isValid&&this.e<=e},e.contains=function(e){return!!this.isValid&&(this.s<=e&&this.e>e)},e.set=function(e){var t=void 0===e?{}:e,n=t.start,r=t.end;return this.isValid?f.fromDateTimes(n||this.s,r||this.e):this},e.splitAt=function(){if(!this.isValid)return[];for(var e=arguments.length,t=new Array(e),n=0;n+this.e?this.e:u;i.push(f.fromDateTimes(o,s)),o=s,a+=1}return i},e.splitBy=function(e){var t=en(e);if(!this.isValid||!t.isValid||0===t.as("milliseconds"))return[];for(var n,r,i=this.s,o=[];i+this.e?this.e:n,o.push(f.fromDateTimes(i,r)),i=r;return o},e.divideEqually=function(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]},e.overlaps=function(e){return this.e>e.s&&this.s=e.e)},e.equals=function(e){return!(!this.isValid||!e.isValid)&&(this.s.equals(e.s)&&this.e.equals(e.e))},e.intersection=function(e){if(!this.isValid)return this;var t=this.s>e.s?this.s:e.s,n=this.ee.e?this.e:e.e;return f.fromDateTimes(t,n)},f.merge=function(e){var t=e.sort(function(e,t){return e.s-t.s}).reduce(function(e,t){var n=e[0],r=e[1];return r?r.overlaps(t)||r.abutsStart(t)?[n,r.union(t)]:[n.concat([r]),t]:[n,t]},[[],null]),n=t[0],r=t[1];return r&&n.push(r),n},f.xor=function(e){var t,n=null,r=0,i=[],o=e.map(function(e){return[{time:e.s,type:"s"},{time:e.e,type:"e"}]}),a=(t=Array.prototype).concat.apply(t,o).sort(function(e,t){return e.time-t.time}),u=Array.isArray(a),s=0;for(a=u?a:a[Symbol.iterator]();;){var c;if(u){if(s>=a.length)break;c=a[s++]}else{if((s=a.next()).done)break;c=s.value}var l=c;n=1===(r+="s"===l.type?1:-1)?l.time:(n&&+n!=+l.time&&i.push(f.fromDateTimes(n,l.time)),null)}return f.merge(i)},e.difference=function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;rx(n)?(t=n+1,u=1):t=n,Object.assign({weekYear:t,weekNumber:u,weekday:a},_(e))}function Mn(e){var t,n=e.weekYear,r=e.weekNumber,i=e.weekday,o=Sn(n,1,4),a=V(n),u=7*r+i-o-3;u<1?u+=V(t=n-1):a=a.length)break;c=a[s++]}else{if((s=a.next()).done)break;c=s.value}var l=c,f=i(l);if(1<=Math.abs(f))return e(f,l)}return e(0,r.units[r.units.length-1])}var Qn=function(){function T(e){var t=e.zone||Re.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new Ut("invalid input"):null)||(t.isValid?null:xn(t));this.ts=M(e.ts)?Re.now():e.ts;var r=null,i=null;if(!n){var o=e.old&&e.old.ts===this.ts&&e.old.zone.equals(t);r=o?e.old.c:jn(this.ts,t.offset(this.ts)),i=o?e.old.o:t.offset(this.ts)}this._zone=t,this.loc=e.loc||nt.create(),this.invalid=n,this.weekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}T.local=function(e,t,n,r,i,o,a){return M(e)?new T({ts:Re.now()}):$n({year:e,month:t,day:n,hour:r,minute:i,second:o,millisecond:a},Re.defaultZone)},T.utc=function(e,t,n,r,i,o,a){return M(e)?new T({ts:Re.now(),zone:Ce.utcInstance}):$n({year:e,month:t,day:n,hour:r,minute:i,second:o,millisecond:a},Ce.utcInstance)},T.fromJSDate=function(e,t){void 0===t&&(t={});var n=function(e){return"[object Date]"===Object.prototype.toString.call(e)}(e)?e.valueOf():NaN;if(Number.isNaN(n))return T.invalid("invalid input");var r=je(t.zone,Re.defaultZone);return r.isValid?new T({ts:n,zone:r,loc:nt.fromObject(t)}):T.invalid(xn(r))},T.fromMillis=function(e,t){if(void 0===t&&(t={}),D(e))return new T({ts:e,zone:je(t.zone,Re.defaultZone),loc:nt.fromObject(t)});throw new h("fromMillis requires a numerical input")},T.fromSeconds=function(e,t){if(void 0===t&&(t={}),D(e))return new T({ts:1e3*e,zone:je(t.zone,Re.defaultZone),loc:nt.fromObject(t)});throw new h("fromSeconds requires a numerical input")},T.fromObject=function(e){var t=je(e.zone,Re.defaultZone);if(!t.isValid)return T.invalid(xn(t));var n=Re.now(),r=t.offset(n),i=A(e,Gn,["zone","locale","outputCalendar","numberingSystem"]),o=!M(i.ordinal),a=!M(i.year),u=!M(i.month)||!M(i.day),s=a||u,c=i.weekYear||i.weekNumber,l=nt.fromObject(e);if((s||o)&&c)throw new N("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(u&&o)throw new N("Can't mix ordinal dates with month/day");var f,d,h=c||i.weekday&&!s,m=jn(n,r);h?(f=Jn,d=Rn,m=Nn(m)):o?(f=Yn,d=Pn,m=Dn(m)):(f=Wn,d=Un);var y=!1,v=f,g=Array.isArray(v),p=0;for(v=g?v:v[Symbol.iterator]();;){var w;if(g){if(p>=v.length)break;w=v[p++]}else{if((p=v.next()).done)break;w=p.value}var k=w;M(i[k])?i[k]=y?d[k]:m[k]:y=!0}var b=(h?function(e){var t=D(e.weekYear),n=E(e.weekNumber,1,x(e.weekYear)),r=E(e.weekday,1,7);return t?n?!r&&bn("weekday",e.weekday):bn("week",e.week):bn("weekYear",e.weekYear)}(i):o?function(e){var t=D(e.year),n=E(e.ordinal,1,V(e.year));return t?!n&&bn("ordinal",e.ordinal):bn("year",e.year)}(i):In(i))||Vn(i);if(b)return T.invalid(b);var S=An(h?Mn(i):o?En(i):i,r,t),O=new T({ts:S[0],zone:t,o:S[1],loc:l});return i.weekday&&s&&e.weekday!==O.weekday?T.invalid("mismatched weekday","you can't specify both a weekday of "+i.weekday+" and a date of "+O.toISO()):O},T.fromISO=function(e,t){void 0===t&&(t={});var n=function(e){return ot(e,[Vt,Ct],[Lt,Zt],[xt,jt],[Ft,At])}(e);return _n(n[0],n[1],t,"ISO 8601",e)},T.fromRFC2822=function(e,t){void 0===t&&(t={});var n=function(e){return ot(function(e){return e.replace(/\([^)]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}(e),[Ot,Tt])}(e);return _n(n[0],n[1],t,"RFC 2822",e)},T.fromHTTP=function(e,t){void 0===t&&(t={});var n=function(e){return ot(e,[Nt,Et],[Mt,Et],[Dt,It])}(e);return _n(n[0],n[1],t,"HTTP",t)},T.fromFormat=function(e,t,n){if(void 0===n&&(n={}),M(e)||M(t))throw new h("fromFormat requires an input string and a format");var r=n,i=r.locale,o=void 0===i?null:i,a=r.numberingSystem,u=void 0===a?null:a,s=function(e,t,n){var r=pn(e,t,n);return[r.result,r.zone,r.invalidReason]}(nt.fromOpts({locale:o,numberingSystem:u,defaultToEN:!0}),e,t),c=s[0],l=s[1],f=s[2];return f?T.invalid(f):_n(c,l,n,"format "+t,e)},T.fromString=function(e,t,n){return void 0===n&&(n={}),T.fromFormat(e,t,n)},T.fromSQL=function(e,t){void 0===t&&(t={});var n=function(e){return ot(e,[zt,qt],[_t,Ht])}(e);return _n(n[0],n[1],t,"SQL",e)},T.invalid=function(e,t){if(void 0===t&&(t=null),!e)throw new h("need to specify a reason the DateTime is invalid");var n=e instanceof Ut?e:new Ut(e,t);if(Re.throwOnInvalid)throw new c(n);return new T({invalid:n})},T.isDateTime=function(e){return e&&e.isLuxonDateTime||!1};var e=T.prototype;return e.get=function(e){return this[e]},e.resolvedLocaleOpts=function(e){void 0===e&&(e={});var t=Je.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t.locale,numberingSystem:t.numberingSystem,outputCalendar:t.calendar}},e.toUTC=function(e,t){return void 0===e&&(e=0),void 0===t&&(t={}),this.setZone(Ce.instance(e),t)},e.toLocal=function(){return this.setZone(Re.defaultZone)},e.setZone=function(e,t){var n=void 0===t?{}:t,r=n.keepLocalTime,i=void 0!==r&&r,o=n.keepCalendarTime,a=void 0!==o&&o;if((e=je(e,Re.defaultZone)).equals(this.zone))return this;if(e.isValid){var u=this.ts;if(i||a){var s=this.o-e.offset(this.ts);u=An(this.toObject(),s,e)[0]}return Cn(this,{ts:u,zone:e})}return T.invalid(xn(e))},e.reconfigure=function(e){var t=void 0===e?{}:e,n=t.locale,r=t.numberingSystem,i=t.outputCalendar,o=this.loc.clone({locale:n,numberingSystem:r,outputCalendar:i});return Cn(this,{loc:o})},e.setLocale=function(e){return this.reconfigure({locale:e})},e.set=function(e){if(!this.isValid)return this;var t,n=A(e,Gn,[]);!M(n.weekYear)||!M(n.weekNumber)||!M(n.weekday)?t=Mn(Object.assign(Nn(this.c),n)):M(n.ordinal)?(t=Object.assign(this.toObject(),n),M(n.day)&&(t.day=Math.min(L(t.year,t.month),t.day))):t=En(Object.assign(Dn(this.c),n));var r=An(t,this.o,this.zone);return Cn(this,{ts:r[0],o:r[1]})},e.plus=function(e){return this.isValid?Cn(this,zn(this,en(e))):this},e.minus=function(e){return this.isValid?Cn(this,zn(this,en(e).negate())):this},e.startOf=function(e){if(!this.isValid)return this;var t={},n=Kt.normalizeUnit(e);switch(n){case"years":t.month=1;case"quarters":case"months":t.day=1;case"weeks":case"days":t.hour=0;case"hours":t.minute=0;case"minutes":t.second=0;case"seconds":t.millisecond=0}if("weeks"===n&&(t.weekday=1),"quarters"===n){var r=Math.ceil(this.month/3);t.month=3*(r-1)+1}return this.set(t)},e.endOf=function(e){var t;return this.isValid?this.plus(((t={})[e]=1,t)).startOf(e).minus(1):this},e.toFormat=function(e,t){return void 0===t&&(t={}),this.isValid?Je.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Ln},e.toLocaleString=function(e){return void 0===e&&(e=W),this.isValid?Je.create(this.loc.clone(e),e).formatDateTime(this):Ln},e.toLocaleParts=function(e){return void 0===e&&(e={}),this.isValid?Je.create(this.loc.clone(e),e).formatDateTimeParts(this):[]},e.toISO=function(e){return void 0===e&&(e={}),this.isValid?this.toISODate()+"T"+this.toISOTime(e):null},e.toISODate=function(){var e="yyyy-MM-dd";return 9999this.valueOf(),a=an(o?this:e,o?e:this,i,r);return o?a.negate():a},e.diffNow=function(e,t){return void 0===e&&(e="milliseconds"),void 0===t&&(t={}),this.diff(T.local(),e,t)},e.until=function(e){return this.isValid?nn.fromDateTimes(this,e):this},e.hasSame=function(e,t){if(!this.isValid)return!1;if("millisecond"===t)return this.valueOf()===e.valueOf();var n=e.valueOf();return this.startOf(t)<=n&&n<=this.endOf(t)},e.equals=function(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)},e.toRelative=function(e){if(void 0===e&&(e={}),!this.isValid)return null;var t=e.base||T.fromObject({zone:this.zone}),n=e.padding?thisthis.set({month:1}).offset||this.offset>this.set({month:5}).offset)}},{key:"isInLeapYear",get:function(){return I(this.year)}},{key:"daysInMonth",get:function(){return L(this.year,this.month)}},{key:"daysInYear",get:function(){return this.isValid?V(this.year):NaN}},{key:"weeksInWeekYear",get:function(){return this.isValid?x(this.weekYear):NaN}}],[{key:"DATE_SHORT",get:function(){return W}},{key:"DATE_MED",get:function(){return J}},{key:"DATE_FULL",get:function(){return Y}},{key:"DATE_HUGE",get:function(){return G}},{key:"TIME_SIMPLE",get:function(){return $}},{key:"TIME_WITH_SECONDS",get:function(){return B}},{key:"TIME_WITH_SHORT_OFFSET",get:function(){return Q}},{key:"TIME_WITH_LONG_OFFSET",get:function(){return X}},{key:"TIME_24_SIMPLE",get:function(){return K}},{key:"TIME_24_WITH_SECONDS",get:function(){return ee}},{key:"TIME_24_WITH_SHORT_OFFSET",get:function(){return te}},{key:"TIME_24_WITH_LONG_OFFSET",get:function(){return ne}},{key:"DATETIME_SHORT",get:function(){return re}},{key:"DATETIME_SHORT_WITH_SECONDS",get:function(){return ie}},{key:"DATETIME_MED",get:function(){return oe}},{key:"DATETIME_MED_WITH_SECONDS",get:function(){return ae}},{key:"DATETIME_FULL",get:function(){return ue}},{key:"DATETIME_FULL_WITH_SECONDS",get:function(){return se}},{key:"DATETIME_HUGE",get:function(){return ce}},{key:"DATETIME_HUGE_WITH_SECONDS",get:function(){return le}}]),T}();function Xn(e){if(Qn.isDateTime(e))return e;if(e&&e.valueOf&&D(e.valueOf()))return Qn.fromJSDate(e);if(e&&"object"==typeof e)return Qn.fromObject(e);throw new h("Unknown datetime argument: "+e+", of type "+typeof e)}return e.DateTime=Qn,e.Duration=Kt,e.FixedOffsetZone=Ce,e.IANAZone=xe,e.Info=rn,e.Interval=nn,e.InvalidZone=Ze,e.LocalZone=De,e.Settings=Re,e.Zone=Ne,e}({});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy