Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

luxon.js 247KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _defineProperties(target, props) {
  4. for (var i = 0; i < props.length; i++) {
  5. var descriptor = props[i];
  6. descriptor.enumerable = descriptor.enumerable || false;
  7. descriptor.configurable = true;
  8. if ("value" in descriptor) descriptor.writable = true;
  9. Object.defineProperty(target, descriptor.key, descriptor);
  10. }
  11. }
  12. function _createClass(Constructor, protoProps, staticProps) {
  13. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14. if (staticProps) _defineProperties(Constructor, staticProps);
  15. return Constructor;
  16. }
  17. function _inheritsLoose(subClass, superClass) {
  18. subClass.prototype = Object.create(superClass.prototype);
  19. subClass.prototype.constructor = subClass;
  20. subClass.__proto__ = superClass;
  21. }
  22. function _getPrototypeOf(o) {
  23. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  24. return o.__proto__ || Object.getPrototypeOf(o);
  25. };
  26. return _getPrototypeOf(o);
  27. }
  28. function _setPrototypeOf(o, p) {
  29. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  30. o.__proto__ = p;
  31. return o;
  32. };
  33. return _setPrototypeOf(o, p);
  34. }
  35. function _isNativeReflectConstruct() {
  36. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  37. if (Reflect.construct.sham) return false;
  38. if (typeof Proxy === "function") return true;
  39. try {
  40. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  41. return true;
  42. } catch (e) {
  43. return false;
  44. }
  45. }
  46. function _construct(Parent, args, Class) {
  47. if (_isNativeReflectConstruct()) {
  48. _construct = Reflect.construct;
  49. } else {
  50. _construct = function _construct(Parent, args, Class) {
  51. var a = [null];
  52. a.push.apply(a, args);
  53. var Constructor = Function.bind.apply(Parent, a);
  54. var instance = new Constructor();
  55. if (Class) _setPrototypeOf(instance, Class.prototype);
  56. return instance;
  57. };
  58. }
  59. return _construct.apply(null, arguments);
  60. }
  61. function _isNativeFunction(fn) {
  62. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  63. }
  64. function _wrapNativeSuper(Class) {
  65. var _cache = typeof Map === "function" ? new Map() : undefined;
  66. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  67. if (Class === null || !_isNativeFunction(Class)) return Class;
  68. if (typeof Class !== "function") {
  69. throw new TypeError("Super expression must either be null or a function");
  70. }
  71. if (typeof _cache !== "undefined") {
  72. if (_cache.has(Class)) return _cache.get(Class);
  73. _cache.set(Class, Wrapper);
  74. }
  75. function Wrapper() {
  76. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  77. }
  78. Wrapper.prototype = Object.create(Class.prototype, {
  79. constructor: {
  80. value: Wrapper,
  81. enumerable: false,
  82. writable: true,
  83. configurable: true
  84. }
  85. });
  86. return _setPrototypeOf(Wrapper, Class);
  87. };
  88. return _wrapNativeSuper(Class);
  89. }
  90. function _objectWithoutPropertiesLoose(source, excluded) {
  91. if (source == null) return {};
  92. var target = {};
  93. var sourceKeys = Object.keys(source);
  94. var key, i;
  95. for (i = 0; i < sourceKeys.length; i++) {
  96. key = sourceKeys[i];
  97. if (excluded.indexOf(key) >= 0) continue;
  98. target[key] = source[key];
  99. }
  100. return target;
  101. }
  102. function _unsupportedIterableToArray(o, minLen) {
  103. if (!o) return;
  104. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  105. var n = Object.prototype.toString.call(o).slice(8, -1);
  106. if (n === "Object" && o.constructor) n = o.constructor.name;
  107. if (n === "Map" || n === "Set") return Array.from(n);
  108. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  109. }
  110. function _arrayLikeToArray(arr, len) {
  111. if (len == null || len > arr.length) len = arr.length;
  112. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  113. return arr2;
  114. }
  115. function _createForOfIteratorHelperLoose(o) {
  116. var i = 0;
  117. if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
  118. if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) return function () {
  119. if (i >= o.length) return {
  120. done: true
  121. };
  122. return {
  123. done: false,
  124. value: o[i++]
  125. };
  126. };
  127. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  128. }
  129. i = o[Symbol.iterator]();
  130. return i.next.bind(i);
  131. }
  132. // these aren't really private, but nor are they really useful to document
  133. /**
  134. * @private
  135. */
  136. var LuxonError = /*#__PURE__*/function (_Error) {
  137. _inheritsLoose(LuxonError, _Error);
  138. function LuxonError() {
  139. return _Error.apply(this, arguments) || this;
  140. }
  141. return LuxonError;
  142. }( /*#__PURE__*/_wrapNativeSuper(Error));
  143. /**
  144. * @private
  145. */
  146. var InvalidDateTimeError = /*#__PURE__*/function (_LuxonError) {
  147. _inheritsLoose(InvalidDateTimeError, _LuxonError);
  148. function InvalidDateTimeError(reason) {
  149. return _LuxonError.call(this, "Invalid DateTime: " + reason.toMessage()) || this;
  150. }
  151. return InvalidDateTimeError;
  152. }(LuxonError);
  153. /**
  154. * @private
  155. */
  156. var InvalidIntervalError = /*#__PURE__*/function (_LuxonError2) {
  157. _inheritsLoose(InvalidIntervalError, _LuxonError2);
  158. function InvalidIntervalError(reason) {
  159. return _LuxonError2.call(this, "Invalid Interval: " + reason.toMessage()) || this;
  160. }
  161. return InvalidIntervalError;
  162. }(LuxonError);
  163. /**
  164. * @private
  165. */
  166. var InvalidDurationError = /*#__PURE__*/function (_LuxonError3) {
  167. _inheritsLoose(InvalidDurationError, _LuxonError3);
  168. function InvalidDurationError(reason) {
  169. return _LuxonError3.call(this, "Invalid Duration: " + reason.toMessage()) || this;
  170. }
  171. return InvalidDurationError;
  172. }(LuxonError);
  173. /**
  174. * @private
  175. */
  176. var ConflictingSpecificationError = /*#__PURE__*/function (_LuxonError4) {
  177. _inheritsLoose(ConflictingSpecificationError, _LuxonError4);
  178. function ConflictingSpecificationError() {
  179. return _LuxonError4.apply(this, arguments) || this;
  180. }
  181. return ConflictingSpecificationError;
  182. }(LuxonError);
  183. /**
  184. * @private
  185. */
  186. var InvalidUnitError = /*#__PURE__*/function (_LuxonError5) {
  187. _inheritsLoose(InvalidUnitError, _LuxonError5);
  188. function InvalidUnitError(unit) {
  189. return _LuxonError5.call(this, "Invalid unit " + unit) || this;
  190. }
  191. return InvalidUnitError;
  192. }(LuxonError);
  193. /**
  194. * @private
  195. */
  196. var InvalidArgumentError = /*#__PURE__*/function (_LuxonError6) {
  197. _inheritsLoose(InvalidArgumentError, _LuxonError6);
  198. function InvalidArgumentError() {
  199. return _LuxonError6.apply(this, arguments) || this;
  200. }
  201. return InvalidArgumentError;
  202. }(LuxonError);
  203. /**
  204. * @private
  205. */
  206. var ZoneIsAbstractError = /*#__PURE__*/function (_LuxonError7) {
  207. _inheritsLoose(ZoneIsAbstractError, _LuxonError7);
  208. function ZoneIsAbstractError() {
  209. return _LuxonError7.call(this, "Zone is an abstract class") || this;
  210. }
  211. return ZoneIsAbstractError;
  212. }(LuxonError);
  213. /**
  214. * @private
  215. */
  216. var n = "numeric",
  217. s = "short",
  218. l = "long";
  219. var DATE_SHORT = {
  220. year: n,
  221. month: n,
  222. day: n
  223. };
  224. var DATE_MED = {
  225. year: n,
  226. month: s,
  227. day: n
  228. };
  229. var DATE_MED_WITH_WEEKDAY = {
  230. year: n,
  231. month: s,
  232. day: n,
  233. weekday: s
  234. };
  235. var DATE_FULL = {
  236. year: n,
  237. month: l,
  238. day: n
  239. };
  240. var DATE_HUGE = {
  241. year: n,
  242. month: l,
  243. day: n,
  244. weekday: l
  245. };
  246. var TIME_SIMPLE = {
  247. hour: n,
  248. minute: n
  249. };
  250. var TIME_WITH_SECONDS = {
  251. hour: n,
  252. minute: n,
  253. second: n
  254. };
  255. var TIME_WITH_SHORT_OFFSET = {
  256. hour: n,
  257. minute: n,
  258. second: n,
  259. timeZoneName: s
  260. };
  261. var TIME_WITH_LONG_OFFSET = {
  262. hour: n,
  263. minute: n,
  264. second: n,
  265. timeZoneName: l
  266. };
  267. var TIME_24_SIMPLE = {
  268. hour: n,
  269. minute: n,
  270. hour12: false
  271. };
  272. /**
  273. * {@link toLocaleString}; format like '09:30:23', always 24-hour.
  274. */
  275. var TIME_24_WITH_SECONDS = {
  276. hour: n,
  277. minute: n,
  278. second: n,
  279. hour12: false
  280. };
  281. /**
  282. * {@link toLocaleString}; format like '09:30:23 EDT', always 24-hour.
  283. */
  284. var TIME_24_WITH_SHORT_OFFSET = {
  285. hour: n,
  286. minute: n,
  287. second: n,
  288. hour12: false,
  289. timeZoneName: s
  290. };
  291. /**
  292. * {@link toLocaleString}; format like '09:30:23 Eastern Daylight Time', always 24-hour.
  293. */
  294. var TIME_24_WITH_LONG_OFFSET = {
  295. hour: n,
  296. minute: n,
  297. second: n,
  298. hour12: false,
  299. timeZoneName: l
  300. };
  301. /**
  302. * {@link toLocaleString}; format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
  303. */
  304. var DATETIME_SHORT = {
  305. year: n,
  306. month: n,
  307. day: n,
  308. hour: n,
  309. minute: n
  310. };
  311. /**
  312. * {@link toLocaleString}; format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
  313. */
  314. var DATETIME_SHORT_WITH_SECONDS = {
  315. year: n,
  316. month: n,
  317. day: n,
  318. hour: n,
  319. minute: n,
  320. second: n
  321. };
  322. var DATETIME_MED = {
  323. year: n,
  324. month: s,
  325. day: n,
  326. hour: n,
  327. minute: n
  328. };
  329. var DATETIME_MED_WITH_SECONDS = {
  330. year: n,
  331. month: s,
  332. day: n,
  333. hour: n,
  334. minute: n,
  335. second: n
  336. };
  337. var DATETIME_MED_WITH_WEEKDAY = {
  338. year: n,
  339. month: s,
  340. day: n,
  341. weekday: s,
  342. hour: n,
  343. minute: n
  344. };
  345. var DATETIME_FULL = {
  346. year: n,
  347. month: l,
  348. day: n,
  349. hour: n,
  350. minute: n,
  351. timeZoneName: s
  352. };
  353. var DATETIME_FULL_WITH_SECONDS = {
  354. year: n,
  355. month: l,
  356. day: n,
  357. hour: n,
  358. minute: n,
  359. second: n,
  360. timeZoneName: s
  361. };
  362. var DATETIME_HUGE = {
  363. year: n,
  364. month: l,
  365. day: n,
  366. weekday: l,
  367. hour: n,
  368. minute: n,
  369. timeZoneName: l
  370. };
  371. var DATETIME_HUGE_WITH_SECONDS = {
  372. year: n,
  373. month: l,
  374. day: n,
  375. weekday: l,
  376. hour: n,
  377. minute: n,
  378. second: n,
  379. timeZoneName: l
  380. };
  381. /*
  382. This is just a junk drawer, containing anything used across multiple classes.
  383. Because Luxon is small(ish), this should stay small and we won't worry about splitting
  384. it up into, say, parsingUtil.js and basicUtil.js and so on. But they are divided up by feature area.
  385. */
  386. /**
  387. * @private
  388. */
  389. // TYPES
  390. function isUndefined(o) {
  391. return typeof o === "undefined";
  392. }
  393. function isNumber(o) {
  394. return typeof o === "number";
  395. }
  396. function isInteger(o) {
  397. return typeof o === "number" && o % 1 === 0;
  398. }
  399. function isString(o) {
  400. return typeof o === "string";
  401. }
  402. function isDate(o) {
  403. return Object.prototype.toString.call(o) === "[object Date]";
  404. } // CAPABILITIES
  405. function hasIntl() {
  406. try {
  407. return typeof Intl !== "undefined" && Intl.DateTimeFormat;
  408. } catch (e) {
  409. return false;
  410. }
  411. }
  412. function hasFormatToParts() {
  413. return !isUndefined(Intl.DateTimeFormat.prototype.formatToParts);
  414. }
  415. function hasRelative() {
  416. try {
  417. return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
  418. } catch (e) {
  419. return false;
  420. }
  421. } // OBJECTS AND ARRAYS
  422. function maybeArray(thing) {
  423. return Array.isArray(thing) ? thing : [thing];
  424. }
  425. function bestBy(arr, by, compare) {
  426. if (arr.length === 0) {
  427. return undefined;
  428. }
  429. return arr.reduce(function (best, next) {
  430. var pair = [by(next), next];
  431. if (!best) {
  432. return pair;
  433. } else if (compare(best[0], pair[0]) === best[0]) {
  434. return best;
  435. } else {
  436. return pair;
  437. }
  438. }, null)[1];
  439. }
  440. function pick(obj, keys) {
  441. return keys.reduce(function (a, k) {
  442. a[k] = obj[k];
  443. return a;
  444. }, {});
  445. }
  446. function hasOwnProperty(obj, prop) {
  447. return Object.prototype.hasOwnProperty.call(obj, prop);
  448. } // NUMBERS AND STRINGS
  449. function integerBetween(thing, bottom, top) {
  450. return isInteger(thing) && thing >= bottom && thing <= top;
  451. } // x % n but takes the sign of n instead of x
  452. function floorMod(x, n) {
  453. return x - n * Math.floor(x / n);
  454. }
  455. function padStart(input, n) {
  456. if (n === void 0) {
  457. n = 2;
  458. }
  459. var minus = input < 0 ? "-" : "";
  460. var target = minus ? input * -1 : input;
  461. var result;
  462. if (target.toString().length < n) {
  463. result = ("0".repeat(n) + target).slice(-n);
  464. } else {
  465. result = target.toString();
  466. }
  467. return "" + minus + result;
  468. }
  469. function parseInteger(string) {
  470. if (isUndefined(string) || string === null || string === "") {
  471. return undefined;
  472. } else {
  473. return parseInt(string, 10);
  474. }
  475. }
  476. function parseMillis(fraction) {
  477. // Return undefined (instead of 0) in these cases, where fraction is not set
  478. if (isUndefined(fraction) || fraction === null || fraction === "") {
  479. return undefined;
  480. } else {
  481. var f = parseFloat("0." + fraction) * 1000;
  482. return Math.floor(f);
  483. }
  484. }
  485. function roundTo(number, digits, towardZero) {
  486. if (towardZero === void 0) {
  487. towardZero = false;
  488. }
  489. var factor = Math.pow(10, digits),
  490. rounder = towardZero ? Math.trunc : Math.round;
  491. return rounder(number * factor) / factor;
  492. } // DATE BASICS
  493. function isLeapYear(year) {
  494. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  495. }
  496. function daysInYear(year) {
  497. return isLeapYear(year) ? 366 : 365;
  498. }
  499. function daysInMonth(year, month) {
  500. var modMonth = floorMod(month - 1, 12) + 1,
  501. modYear = year + (month - modMonth) / 12;
  502. if (modMonth === 2) {
  503. return isLeapYear(modYear) ? 29 : 28;
  504. } else {
  505. return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
  506. }
  507. } // covert a calendar object to a local timestamp (epoch, but with the offset baked in)
  508. function objToLocalTS(obj) {
  509. var d = Date.UTC(obj.year, obj.month - 1, obj.day, obj.hour, obj.minute, obj.second, obj.millisecond); // for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that
  510. if (obj.year < 100 && obj.year >= 0) {
  511. d = new Date(d);
  512. d.setUTCFullYear(d.getUTCFullYear() - 1900);
  513. }
  514. return +d;
  515. }
  516. function weeksInWeekYear(weekYear) {
  517. var p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7,
  518. last = weekYear - 1,
  519. p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
  520. return p1 === 4 || p2 === 3 ? 53 : 52;
  521. }
  522. function untruncateYear(year) {
  523. if (year > 99) {
  524. return year;
  525. } else return year > 60 ? 1900 + year : 2000 + year;
  526. } // PARSING
  527. function parseZoneInfo(ts, offsetFormat, locale, timeZone) {
  528. if (timeZone === void 0) {
  529. timeZone = null;
  530. }
  531. var date = new Date(ts),
  532. intlOpts = {
  533. hour12: false,
  534. year: "numeric",
  535. month: "2-digit",
  536. day: "2-digit",
  537. hour: "2-digit",
  538. minute: "2-digit"
  539. };
  540. if (timeZone) {
  541. intlOpts.timeZone = timeZone;
  542. }
  543. var modified = Object.assign({
  544. timeZoneName: offsetFormat
  545. }, intlOpts),
  546. intl = hasIntl();
  547. if (intl && hasFormatToParts()) {
  548. var parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find(function (m) {
  549. return m.type.toLowerCase() === "timezonename";
  550. });
  551. return parsed ? parsed.value : null;
  552. } else if (intl) {
  553. // this probably doesn't work for all locales
  554. var without = new Intl.DateTimeFormat(locale, intlOpts).format(date),
  555. included = new Intl.DateTimeFormat(locale, modified).format(date),
  556. diffed = included.substring(without.length),
  557. trimmed = diffed.replace(/^[, \u200e]+/, "");
  558. return trimmed;
  559. } else {
  560. return null;
  561. }
  562. } // signedOffset('-5', '30') -> -330
  563. function signedOffset(offHourStr, offMinuteStr) {
  564. var offHour = parseInt(offHourStr, 10); // don't || this because we want to preserve -0
  565. if (Number.isNaN(offHour)) {
  566. offHour = 0;
  567. }
  568. var offMin = parseInt(offMinuteStr, 10) || 0,
  569. offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
  570. return offHour * 60 + offMinSigned;
  571. } // COERCION
  572. function asNumber(value) {
  573. var numericValue = Number(value);
  574. if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue)) throw new InvalidArgumentError("Invalid unit value " + value);
  575. return numericValue;
  576. }
  577. function normalizeObject(obj, normalizer, nonUnitKeys) {
  578. var normalized = {};
  579. for (var u in obj) {
  580. if (hasOwnProperty(obj, u)) {
  581. if (nonUnitKeys.indexOf(u) >= 0) continue;
  582. var v = obj[u];
  583. if (v === undefined || v === null) continue;
  584. normalized[normalizer(u)] = asNumber(v);
  585. }
  586. }
  587. return normalized;
  588. }
  589. function formatOffset(offset, format) {
  590. var hours = Math.trunc(Math.abs(offset / 60)),
  591. minutes = Math.trunc(Math.abs(offset % 60)),
  592. sign = offset >= 0 ? "+" : "-";
  593. switch (format) {
  594. case "short":
  595. return "" + sign + padStart(hours, 2) + ":" + padStart(minutes, 2);
  596. case "narrow":
  597. return "" + sign + hours + (minutes > 0 ? ":" + minutes : "");
  598. case "techie":
  599. return "" + sign + padStart(hours, 2) + padStart(minutes, 2);
  600. default:
  601. throw new RangeError("Value format " + format + " is out of range for property format");
  602. }
  603. }
  604. function timeObject(obj) {
  605. return pick(obj, ["hour", "minute", "second", "millisecond"]);
  606. }
  607. var ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z_+-]{1,256}(\/[A-Za-z_+-]{1,256})?)?/;
  608. function stringify(obj) {
  609. return JSON.stringify(obj, Object.keys(obj).sort());
  610. }
  611. /**
  612. * @private
  613. */
  614. var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  615. var monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  616. var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
  617. function months(length) {
  618. switch (length) {
  619. case "narrow":
  620. return [].concat(monthsNarrow);
  621. case "short":
  622. return [].concat(monthsShort);
  623. case "long":
  624. return [].concat(monthsLong);
  625. case "numeric":
  626. return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
  627. case "2-digit":
  628. return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  629. default:
  630. return null;
  631. }
  632. }
  633. var weekdaysLong = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
  634. var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
  635. var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"];
  636. function weekdays(length) {
  637. switch (length) {
  638. case "narrow":
  639. return [].concat(weekdaysNarrow);
  640. case "short":
  641. return [].concat(weekdaysShort);
  642. case "long":
  643. return [].concat(weekdaysLong);
  644. case "numeric":
  645. return ["1", "2", "3", "4", "5", "6", "7"];
  646. default:
  647. return null;
  648. }
  649. }
  650. var meridiems = ["AM", "PM"];
  651. var erasLong = ["Before Christ", "Anno Domini"];
  652. var erasShort = ["BC", "AD"];
  653. var erasNarrow = ["B", "A"];
  654. function eras(length) {
  655. switch (length) {
  656. case "narrow":
  657. return [].concat(erasNarrow);
  658. case "short":
  659. return [].concat(erasShort);
  660. case "long":
  661. return [].concat(erasLong);
  662. default:
  663. return null;
  664. }
  665. }
  666. function meridiemForDateTime(dt) {
  667. return meridiems[dt.hour < 12 ? 0 : 1];
  668. }
  669. function weekdayForDateTime(dt, length) {
  670. return weekdays(length)[dt.weekday - 1];
  671. }
  672. function monthForDateTime(dt, length) {
  673. return months(length)[dt.month - 1];
  674. }
  675. function eraForDateTime(dt, length) {
  676. return eras(length)[dt.year < 0 ? 0 : 1];
  677. }
  678. function formatRelativeTime(unit, count, numeric, narrow) {
  679. if (numeric === void 0) {
  680. numeric = "always";
  681. }
  682. if (narrow === void 0) {
  683. narrow = false;
  684. }
  685. var units = {
  686. years: ["year", "yr."],
  687. quarters: ["quarter", "qtr."],
  688. months: ["month", "mo."],
  689. weeks: ["week", "wk."],
  690. days: ["day", "day", "days"],
  691. hours: ["hour", "hr."],
  692. minutes: ["minute", "min."],
  693. seconds: ["second", "sec."]
  694. };
  695. var lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
  696. if (numeric === "auto" && lastable) {
  697. var isDay = unit === "days";
  698. switch (count) {
  699. case 1:
  700. return isDay ? "tomorrow" : "next " + units[unit][0];
  701. case -1:
  702. return isDay ? "yesterday" : "last " + units[unit][0];
  703. case 0:
  704. return isDay ? "today" : "this " + units[unit][0];
  705. }
  706. }
  707. var isInPast = Object.is(count, -0) || count < 0,
  708. fmtValue = Math.abs(count),
  709. singular = fmtValue === 1,
  710. lilUnits = units[unit],
  711. fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit;
  712. return isInPast ? fmtValue + " " + fmtUnit + " ago" : "in " + fmtValue + " " + fmtUnit;
  713. }
  714. function formatString(knownFormat) {
  715. // these all have the offsets removed because we don't have access to them
  716. // without all the intl stuff this is backfilling
  717. var filtered = pick(knownFormat, ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName", "hour12"]),
  718. key = stringify(filtered),
  719. dateTimeHuge = "EEEE, LLLL d, yyyy, h:mm a";
  720. switch (key) {
  721. case stringify(DATE_SHORT):
  722. return "M/d/yyyy";
  723. case stringify(DATE_MED):
  724. return "LLL d, yyyy";
  725. case stringify(DATE_MED_WITH_WEEKDAY):
  726. return "EEE, LLL d, yyyy";
  727. case stringify(DATE_FULL):
  728. return "LLLL d, yyyy";
  729. case stringify(DATE_HUGE):
  730. return "EEEE, LLLL d, yyyy";
  731. case stringify(TIME_SIMPLE):
  732. return "h:mm a";
  733. case stringify(TIME_WITH_SECONDS):
  734. return "h:mm:ss a";
  735. case stringify(TIME_WITH_SHORT_OFFSET):
  736. return "h:mm a";
  737. case stringify(TIME_WITH_LONG_OFFSET):
  738. return "h:mm a";
  739. case stringify(TIME_24_SIMPLE):
  740. return "HH:mm";
  741. case stringify(TIME_24_WITH_SECONDS):
  742. return "HH:mm:ss";
  743. case stringify(TIME_24_WITH_SHORT_OFFSET):
  744. return "HH:mm";
  745. case stringify(TIME_24_WITH_LONG_OFFSET):
  746. return "HH:mm";
  747. case stringify(DATETIME_SHORT):
  748. return "M/d/yyyy, h:mm a";
  749. case stringify(DATETIME_MED):
  750. return "LLL d, yyyy, h:mm a";
  751. case stringify(DATETIME_FULL):
  752. return "LLLL d, yyyy, h:mm a";
  753. case stringify(DATETIME_HUGE):
  754. return dateTimeHuge;
  755. case stringify(DATETIME_SHORT_WITH_SECONDS):
  756. return "M/d/yyyy, h:mm:ss a";
  757. case stringify(DATETIME_MED_WITH_SECONDS):
  758. return "LLL d, yyyy, h:mm:ss a";
  759. case stringify(DATETIME_MED_WITH_WEEKDAY):
  760. return "EEE, d LLL yyyy, h:mm a";
  761. case stringify(DATETIME_FULL_WITH_SECONDS):
  762. return "LLLL d, yyyy, h:mm:ss a";
  763. case stringify(DATETIME_HUGE_WITH_SECONDS):
  764. return "EEEE, LLLL d, yyyy, h:mm:ss a";
  765. default:
  766. return dateTimeHuge;
  767. }
  768. }
  769. function stringifyTokens(splits, tokenToString) {
  770. var s = "";
  771. for (var _iterator = _createForOfIteratorHelperLoose(splits), _step; !(_step = _iterator()).done;) {
  772. var token = _step.value;
  773. if (token.literal) {
  774. s += token.val;
  775. } else {
  776. s += tokenToString(token.val);
  777. }
  778. }
  779. return s;
  780. }
  781. var _macroTokenToFormatOpts = {
  782. D: DATE_SHORT,
  783. DD: DATE_MED,
  784. DDD: DATE_FULL,
  785. DDDD: DATE_HUGE,
  786. t: TIME_SIMPLE,
  787. tt: TIME_WITH_SECONDS,
  788. ttt: TIME_WITH_SHORT_OFFSET,
  789. tttt: TIME_WITH_LONG_OFFSET,
  790. T: TIME_24_SIMPLE,
  791. TT: TIME_24_WITH_SECONDS,
  792. TTT: TIME_24_WITH_SHORT_OFFSET,
  793. TTTT: TIME_24_WITH_LONG_OFFSET,
  794. f: DATETIME_SHORT,
  795. ff: DATETIME_MED,
  796. fff: DATETIME_FULL,
  797. ffff: DATETIME_HUGE,
  798. F: DATETIME_SHORT_WITH_SECONDS,
  799. FF: DATETIME_MED_WITH_SECONDS,
  800. FFF: DATETIME_FULL_WITH_SECONDS,
  801. FFFF: DATETIME_HUGE_WITH_SECONDS
  802. };
  803. /**
  804. * @private
  805. */
  806. var Formatter = /*#__PURE__*/function () {
  807. Formatter.create = function create(locale, opts) {
  808. if (opts === void 0) {
  809. opts = {};
  810. }
  811. return new Formatter(locale, opts);
  812. };
  813. Formatter.parseFormat = function parseFormat(fmt) {
  814. var current = null,
  815. currentFull = "",
  816. bracketed = false;
  817. var splits = [];
  818. for (var i = 0; i < fmt.length; i++) {
  819. var c = fmt.charAt(i);
  820. if (c === "'") {
  821. if (currentFull.length > 0) {
  822. splits.push({
  823. literal: bracketed,
  824. val: currentFull
  825. });
  826. }
  827. current = null;
  828. currentFull = "";
  829. bracketed = !bracketed;
  830. } else if (bracketed) {
  831. currentFull += c;
  832. } else if (c === current) {
  833. currentFull += c;
  834. } else {
  835. if (currentFull.length > 0) {
  836. splits.push({
  837. literal: false,
  838. val: currentFull
  839. });
  840. }
  841. currentFull = c;
  842. current = c;
  843. }
  844. }
  845. if (currentFull.length > 0) {
  846. splits.push({
  847. literal: bracketed,
  848. val: currentFull
  849. });
  850. }
  851. return splits;
  852. };
  853. Formatter.macroTokenToFormatOpts = function macroTokenToFormatOpts(token) {
  854. return _macroTokenToFormatOpts[token];
  855. };
  856. function Formatter(locale, formatOpts) {
  857. this.opts = formatOpts;
  858. this.loc = locale;
  859. this.systemLoc = null;
  860. }
  861. var _proto = Formatter.prototype;
  862. _proto.formatWithSystemDefault = function formatWithSystemDefault(dt, opts) {
  863. if (this.systemLoc === null) {
  864. this.systemLoc = this.loc.redefaultToSystem();
  865. }
  866. var df = this.systemLoc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  867. return df.format();
  868. };
  869. _proto.formatDateTime = function formatDateTime(dt, opts) {
  870. if (opts === void 0) {
  871. opts = {};
  872. }
  873. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  874. return df.format();
  875. };
  876. _proto.formatDateTimeParts = function formatDateTimeParts(dt, opts) {
  877. if (opts === void 0) {
  878. opts = {};
  879. }
  880. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  881. return df.formatToParts();
  882. };
  883. _proto.resolvedOptions = function resolvedOptions(dt, opts) {
  884. if (opts === void 0) {
  885. opts = {};
  886. }
  887. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  888. return df.resolvedOptions();
  889. };
  890. _proto.num = function num(n, p) {
  891. if (p === void 0) {
  892. p = 0;
  893. }
  894. // we get some perf out of doing this here, annoyingly
  895. if (this.opts.forceSimple) {
  896. return padStart(n, p);
  897. }
  898. var opts = Object.assign({}, this.opts);
  899. if (p > 0) {
  900. opts.padTo = p;
  901. }
  902. return this.loc.numberFormatter(opts).format(n);
  903. };
  904. _proto.formatDateTimeFromString = function formatDateTimeFromString(dt, fmt) {
  905. var _this = this;
  906. var knownEnglish = this.loc.listingMode() === "en",
  907. useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory" && hasFormatToParts(),
  908. string = function string(opts, extract) {
  909. return _this.loc.extract(dt, opts, extract);
  910. },
  911. formatOffset = function formatOffset(opts) {
  912. if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
  913. return "Z";
  914. }
  915. return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
  916. },
  917. meridiem = function meridiem() {
  918. return knownEnglish ? meridiemForDateTime(dt) : string({
  919. hour: "numeric",
  920. hour12: true
  921. }, "dayperiod");
  922. },
  923. month = function month(length, standalone) {
  924. return knownEnglish ? monthForDateTime(dt, length) : string(standalone ? {
  925. month: length
  926. } : {
  927. month: length,
  928. day: "numeric"
  929. }, "month");
  930. },
  931. weekday = function weekday(length, standalone) {
  932. return knownEnglish ? weekdayForDateTime(dt, length) : string(standalone ? {
  933. weekday: length
  934. } : {
  935. weekday: length,
  936. month: "long",
  937. day: "numeric"
  938. }, "weekday");
  939. },
  940. maybeMacro = function maybeMacro(token) {
  941. var formatOpts = Formatter.macroTokenToFormatOpts(token);
  942. if (formatOpts) {
  943. return _this.formatWithSystemDefault(dt, formatOpts);
  944. } else {
  945. return token;
  946. }
  947. },
  948. era = function era(length) {
  949. return knownEnglish ? eraForDateTime(dt, length) : string({
  950. era: length
  951. }, "era");
  952. },
  953. tokenToString = function tokenToString(token) {
  954. // Where possible: http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles
  955. switch (token) {
  956. // ms
  957. case "S":
  958. return _this.num(dt.millisecond);
  959. case "u": // falls through
  960. case "SSS":
  961. return _this.num(dt.millisecond, 3);
  962. // seconds
  963. case "s":
  964. return _this.num(dt.second);
  965. case "ss":
  966. return _this.num(dt.second, 2);
  967. // minutes
  968. case "m":
  969. return _this.num(dt.minute);
  970. case "mm":
  971. return _this.num(dt.minute, 2);
  972. // hours
  973. case "h":
  974. return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12);
  975. case "hh":
  976. return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2);
  977. case "H":
  978. return _this.num(dt.hour);
  979. case "HH":
  980. return _this.num(dt.hour, 2);
  981. // offset
  982. case "Z":
  983. // like +6
  984. return formatOffset({
  985. format: "narrow",
  986. allowZ: _this.opts.allowZ
  987. });
  988. case "ZZ":
  989. // like +06:00
  990. return formatOffset({
  991. format: "short",
  992. allowZ: _this.opts.allowZ
  993. });
  994. case "ZZZ":
  995. // like +0600
  996. return formatOffset({
  997. format: "techie",
  998. allowZ: _this.opts.allowZ
  999. });
  1000. case "ZZZZ":
  1001. // like EST
  1002. return dt.zone.offsetName(dt.ts, {
  1003. format: "short",
  1004. locale: _this.loc.locale
  1005. });
  1006. case "ZZZZZ":
  1007. // like Eastern Standard Time
  1008. return dt.zone.offsetName(dt.ts, {
  1009. format: "long",
  1010. locale: _this.loc.locale
  1011. });
  1012. // zone
  1013. case "z":
  1014. // like America/New_York
  1015. return dt.zoneName;
  1016. // meridiems
  1017. case "a":
  1018. return meridiem();
  1019. // dates
  1020. case "d":
  1021. return useDateTimeFormatter ? string({
  1022. day: "numeric"
  1023. }, "day") : _this.num(dt.day);
  1024. case "dd":
  1025. return useDateTimeFormatter ? string({
  1026. day: "2-digit"
  1027. }, "day") : _this.num(dt.day, 2);
  1028. // weekdays - standalone
  1029. case "c":
  1030. // like 1
  1031. return _this.num(dt.weekday);
  1032. case "ccc":
  1033. // like 'Tues'
  1034. return weekday("short", true);
  1035. case "cccc":
  1036. // like 'Tuesday'
  1037. return weekday("long", true);
  1038. case "ccccc":
  1039. // like 'T'
  1040. return weekday("narrow", true);
  1041. // weekdays - format
  1042. case "E":
  1043. // like 1
  1044. return _this.num(dt.weekday);
  1045. case "EEE":
  1046. // like 'Tues'
  1047. return weekday("short", false);
  1048. case "EEEE":
  1049. // like 'Tuesday'
  1050. return weekday("long", false);
  1051. case "EEEEE":
  1052. // like 'T'
  1053. return weekday("narrow", false);
  1054. // months - standalone
  1055. case "L":
  1056. // like 1
  1057. return useDateTimeFormatter ? string({
  1058. month: "numeric",
  1059. day: "numeric"
  1060. }, "month") : _this.num(dt.month);
  1061. case "LL":
  1062. // like 01, doesn't seem to work
  1063. return useDateTimeFormatter ? string({
  1064. month: "2-digit",
  1065. day: "numeric"
  1066. }, "month") : _this.num(dt.month, 2);
  1067. case "LLL":
  1068. // like Jan
  1069. return month("short", true);
  1070. case "LLLL":
  1071. // like January
  1072. return month("long", true);
  1073. case "LLLLL":
  1074. // like J
  1075. return month("narrow", true);
  1076. // months - format
  1077. case "M":
  1078. // like 1
  1079. return useDateTimeFormatter ? string({
  1080. month: "numeric"
  1081. }, "month") : _this.num(dt.month);
  1082. case "MM":
  1083. // like 01
  1084. return useDateTimeFormatter ? string({
  1085. month: "2-digit"
  1086. }, "month") : _this.num(dt.month, 2);
  1087. case "MMM":
  1088. // like Jan
  1089. return month("short", false);
  1090. case "MMMM":
  1091. // like January
  1092. return month("long", false);
  1093. case "MMMMM":
  1094. // like J
  1095. return month("narrow", false);
  1096. // years
  1097. case "y":
  1098. // like 2014
  1099. return useDateTimeFormatter ? string({
  1100. year: "numeric"
  1101. }, "year") : _this.num(dt.year);
  1102. case "yy":
  1103. // like 14
  1104. return useDateTimeFormatter ? string({
  1105. year: "2-digit"
  1106. }, "year") : _this.num(dt.year.toString().slice(-2), 2);
  1107. case "yyyy":
  1108. // like 0012
  1109. return useDateTimeFormatter ? string({
  1110. year: "numeric"
  1111. }, "year") : _this.num(dt.year, 4);
  1112. case "yyyyyy":
  1113. // like 000012
  1114. return useDateTimeFormatter ? string({
  1115. year: "numeric"
  1116. }, "year") : _this.num(dt.year, 6);
  1117. // eras
  1118. case "G":
  1119. // like AD
  1120. return era("short");
  1121. case "GG":
  1122. // like Anno Domini
  1123. return era("long");
  1124. case "GGGGG":
  1125. return era("narrow");
  1126. case "kk":
  1127. return _this.num(dt.weekYear.toString().slice(-2), 2);
  1128. case "kkkk":
  1129. return _this.num(dt.weekYear, 4);
  1130. case "W":
  1131. return _this.num(dt.weekNumber);
  1132. case "WW":
  1133. return _this.num(dt.weekNumber, 2);
  1134. case "o":
  1135. return _this.num(dt.ordinal);
  1136. case "ooo":
  1137. return _this.num(dt.ordinal, 3);
  1138. case "q":
  1139. // like 1
  1140. return _this.num(dt.quarter);
  1141. case "qq":
  1142. // like 01
  1143. return _this.num(dt.quarter, 2);
  1144. case "X":
  1145. return _this.num(Math.floor(dt.ts / 1000));
  1146. case "x":
  1147. return _this.num(dt.ts);
  1148. default:
  1149. return maybeMacro(token);
  1150. }
  1151. };
  1152. return stringifyTokens(Formatter.parseFormat(fmt), tokenToString);
  1153. };
  1154. _proto.formatDurationFromString = function formatDurationFromString(dur, fmt) {
  1155. var _this2 = this;
  1156. var tokenToField = function tokenToField(token) {
  1157. switch (token[0]) {
  1158. case "S":
  1159. return "millisecond";
  1160. case "s":
  1161. return "second";
  1162. case "m":
  1163. return "minute";
  1164. case "h":
  1165. return "hour";
  1166. case "d":
  1167. return "day";
  1168. case "M":
  1169. return "month";
  1170. case "y":
  1171. return "year";
  1172. default:
  1173. return null;
  1174. }
  1175. },
  1176. tokenToString = function tokenToString(lildur) {
  1177. return function (token) {
  1178. var mapped = tokenToField(token);
  1179. if (mapped) {
  1180. return _this2.num(lildur.get(mapped), token.length);
  1181. } else {
  1182. return token;
  1183. }
  1184. };
  1185. },
  1186. tokens = Formatter.parseFormat(fmt),
  1187. realTokens = tokens.reduce(function (found, _ref) {
  1188. var literal = _ref.literal,
  1189. val = _ref.val;
  1190. return literal ? found : found.concat(val);
  1191. }, []),
  1192. collapsed = dur.shiftTo.apply(dur, realTokens.map(tokenToField).filter(function (t) {
  1193. return t;
  1194. }));
  1195. return stringifyTokens(tokens, tokenToString(collapsed));
  1196. };
  1197. return Formatter;
  1198. }();
  1199. var Invalid = /*#__PURE__*/function () {
  1200. function Invalid(reason, explanation) {
  1201. this.reason = reason;
  1202. this.explanation = explanation;
  1203. }
  1204. var _proto = Invalid.prototype;
  1205. _proto.toMessage = function toMessage() {
  1206. if (this.explanation) {
  1207. return this.reason + ": " + this.explanation;
  1208. } else {
  1209. return this.reason;
  1210. }
  1211. };
  1212. return Invalid;
  1213. }();
  1214. /**
  1215. * @interface
  1216. */
  1217. var Zone = /*#__PURE__*/function () {
  1218. function Zone() {}
  1219. var _proto = Zone.prototype;
  1220. /**
  1221. * Returns the offset's common name (such as EST) at the specified timestamp
  1222. * @abstract
  1223. * @param {number} ts - Epoch milliseconds for which to get the name
  1224. * @param {Object} opts - Options to affect the format
  1225. * @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
  1226. * @param {string} opts.locale - What locale to return the offset name in.
  1227. * @return {string}
  1228. */
  1229. _proto.offsetName = function offsetName(ts, opts) {
  1230. throw new ZoneIsAbstractError();
  1231. }
  1232. /**
  1233. * Returns the offset's value as a string
  1234. * @abstract
  1235. * @param {number} ts - Epoch milliseconds for which to get the offset
  1236. * @param {string} format - What style of offset to return.
  1237. * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
  1238. * @return {string}
  1239. */
  1240. ;
  1241. _proto.formatOffset = function formatOffset(ts, format) {
  1242. throw new ZoneIsAbstractError();
  1243. }
  1244. /**
  1245. * Return the offset in minutes for this zone at the specified timestamp.
  1246. * @abstract
  1247. * @param {number} ts - Epoch milliseconds for which to compute the offset
  1248. * @return {number}
  1249. */
  1250. ;
  1251. _proto.offset = function offset(ts) {
  1252. throw new ZoneIsAbstractError();
  1253. }
  1254. /**
  1255. * Return whether this Zone is equal to another zone
  1256. * @abstract
  1257. * @param {Zone} otherZone - the zone to compare
  1258. * @return {boolean}
  1259. */
  1260. ;
  1261. _proto.equals = function equals(otherZone) {
  1262. throw new ZoneIsAbstractError();
  1263. }
  1264. /**
  1265. * Return whether this Zone is valid.
  1266. * @abstract
  1267. * @type {boolean}
  1268. */
  1269. ;
  1270. _createClass(Zone, [{
  1271. key: "type",
  1272. /**
  1273. * The type of zone
  1274. * @abstract
  1275. * @type {string}
  1276. */
  1277. get: function get() {
  1278. throw new ZoneIsAbstractError();
  1279. }
  1280. /**
  1281. * The name of this zone.
  1282. * @abstract
  1283. * @type {string}
  1284. */
  1285. }, {
  1286. key: "name",
  1287. get: function get() {
  1288. throw new ZoneIsAbstractError();
  1289. }
  1290. /**
  1291. * Returns whether the offset is known to be fixed for the whole year.
  1292. * @abstract
  1293. * @type {boolean}
  1294. */
  1295. }, {
  1296. key: "universal",
  1297. get: function get() {
  1298. throw new ZoneIsAbstractError();
  1299. }
  1300. }, {
  1301. key: "isValid",
  1302. get: function get() {
  1303. throw new ZoneIsAbstractError();
  1304. }
  1305. }]);
  1306. return Zone;
  1307. }();
  1308. var singleton = null;
  1309. /**
  1310. * Represents the local zone for this JavaScript environment.
  1311. * @implements {Zone}
  1312. */
  1313. var LocalZone = /*#__PURE__*/function (_Zone) {
  1314. _inheritsLoose(LocalZone, _Zone);
  1315. function LocalZone() {
  1316. return _Zone.apply(this, arguments) || this;
  1317. }
  1318. var _proto = LocalZone.prototype;
  1319. /** @override **/
  1320. _proto.offsetName = function offsetName(ts, _ref) {
  1321. var format = _ref.format,
  1322. locale = _ref.locale;
  1323. return parseZoneInfo(ts, format, locale);
  1324. }
  1325. /** @override **/
  1326. ;
  1327. _proto.formatOffset = function formatOffset$1(ts, format) {
  1328. return formatOffset(this.offset(ts), format);
  1329. }
  1330. /** @override **/
  1331. ;
  1332. _proto.offset = function offset(ts) {
  1333. return -new Date(ts).getTimezoneOffset();
  1334. }
  1335. /** @override **/
  1336. ;
  1337. _proto.equals = function equals(otherZone) {
  1338. return otherZone.type === "local";
  1339. }
  1340. /** @override **/
  1341. ;
  1342. _createClass(LocalZone, [{
  1343. key: "type",
  1344. /** @override **/
  1345. get: function get() {
  1346. return "local";
  1347. }
  1348. /** @override **/
  1349. }, {
  1350. key: "name",
  1351. get: function get() {
  1352. if (hasIntl()) {
  1353. return new Intl.DateTimeFormat().resolvedOptions().timeZone;
  1354. } else return "local";
  1355. }
  1356. /** @override **/
  1357. }, {
  1358. key: "universal",
  1359. get: function get() {
  1360. return false;
  1361. }
  1362. }, {
  1363. key: "isValid",
  1364. get: function get() {
  1365. return true;
  1366. }
  1367. }], [{
  1368. key: "instance",
  1369. /**
  1370. * Get a singleton instance of the local zone
  1371. * @return {LocalZone}
  1372. */
  1373. get: function get() {
  1374. if (singleton === null) {
  1375. singleton = new LocalZone();
  1376. }
  1377. return singleton;
  1378. }
  1379. }]);
  1380. return LocalZone;
  1381. }(Zone);
  1382. var matchingRegex = RegExp("^" + ianaRegex.source + "$");
  1383. var dtfCache = {};
  1384. function makeDTF(zone) {
  1385. if (!dtfCache[zone]) {
  1386. dtfCache[zone] = new Intl.DateTimeFormat("en-US", {
  1387. hour12: false,
  1388. timeZone: zone,
  1389. year: "numeric",
  1390. month: "2-digit",
  1391. day: "2-digit",
  1392. hour: "2-digit",
  1393. minute: "2-digit",
  1394. second: "2-digit"
  1395. });
  1396. }
  1397. return dtfCache[zone];
  1398. }
  1399. var typeToPos = {
  1400. year: 0,
  1401. month: 1,
  1402. day: 2,
  1403. hour: 3,
  1404. minute: 4,
  1405. second: 5
  1406. };
  1407. function hackyOffset(dtf, date) {
  1408. var formatted = dtf.format(date).replace(/\u200E/g, ""),
  1409. parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted),
  1410. fMonth = parsed[1],
  1411. fDay = parsed[2],
  1412. fYear = parsed[3],
  1413. fHour = parsed[4],
  1414. fMinute = parsed[5],
  1415. fSecond = parsed[6];
  1416. return [fYear, fMonth, fDay, fHour, fMinute, fSecond];
  1417. }
  1418. function partsOffset(dtf, date) {
  1419. var formatted = dtf.formatToParts(date),
  1420. filled = [];
  1421. for (var i = 0; i < formatted.length; i++) {
  1422. var _formatted$i = formatted[i],
  1423. type = _formatted$i.type,
  1424. value = _formatted$i.value,
  1425. pos = typeToPos[type];
  1426. if (!isUndefined(pos)) {
  1427. filled[pos] = parseInt(value, 10);
  1428. }
  1429. }
  1430. return filled;
  1431. }
  1432. var ianaZoneCache = {};
  1433. /**
  1434. * A zone identified by an IANA identifier, like America/New_York
  1435. * @implements {Zone}
  1436. */
  1437. var IANAZone = /*#__PURE__*/function (_Zone) {
  1438. _inheritsLoose(IANAZone, _Zone);
  1439. /**
  1440. * @param {string} name - Zone name
  1441. * @return {IANAZone}
  1442. */
  1443. IANAZone.create = function create(name) {
  1444. if (!ianaZoneCache[name]) {
  1445. ianaZoneCache[name] = new IANAZone(name);
  1446. }
  1447. return ianaZoneCache[name];
  1448. }
  1449. /**
  1450. * Reset local caches. Should only be necessary in testing scenarios.
  1451. * @return {void}
  1452. */
  1453. ;
  1454. IANAZone.resetCache = function resetCache() {
  1455. ianaZoneCache = {};
  1456. dtfCache = {};
  1457. }
  1458. /**
  1459. * Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that.
  1460. * @param {string} s - The string to check validity on
  1461. * @example IANAZone.isValidSpecifier("America/New_York") //=> true
  1462. * @example IANAZone.isValidSpecifier("Fantasia/Castle") //=> true
  1463. * @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false
  1464. * @return {boolean}
  1465. */
  1466. ;
  1467. IANAZone.isValidSpecifier = function isValidSpecifier(s) {
  1468. return !!(s && s.match(matchingRegex));
  1469. }
  1470. /**
  1471. * Returns whether the provided string identifies a real zone
  1472. * @param {string} zone - The string to check
  1473. * @example IANAZone.isValidZone("America/New_York") //=> true
  1474. * @example IANAZone.isValidZone("Fantasia/Castle") //=> false
  1475. * @example IANAZone.isValidZone("Sport~~blorp") //=> false
  1476. * @return {boolean}
  1477. */
  1478. ;
  1479. IANAZone.isValidZone = function isValidZone(zone) {
  1480. try {
  1481. new Intl.DateTimeFormat("en-US", {
  1482. timeZone: zone
  1483. }).format();
  1484. return true;
  1485. } catch (e) {
  1486. return false;
  1487. }
  1488. } // Etc/GMT+8 -> -480
  1489. /** @ignore */
  1490. ;
  1491. IANAZone.parseGMTOffset = function parseGMTOffset(specifier) {
  1492. if (specifier) {
  1493. var match = specifier.match(/^Etc\/GMT(0|[+-]\d{1,2})$/i);
  1494. if (match) {
  1495. return -60 * parseInt(match[1]);
  1496. }
  1497. }
  1498. return null;
  1499. };
  1500. function IANAZone(name) {
  1501. var _this;
  1502. _this = _Zone.call(this) || this;
  1503. /** @private **/
  1504. _this.zoneName = name;
  1505. /** @private **/
  1506. _this.valid = IANAZone.isValidZone(name);
  1507. return _this;
  1508. }
  1509. /** @override **/
  1510. var _proto = IANAZone.prototype;
  1511. /** @override **/
  1512. _proto.offsetName = function offsetName(ts, _ref) {
  1513. var format = _ref.format,
  1514. locale = _ref.locale;
  1515. return parseZoneInfo(ts, format, locale, this.name);
  1516. }
  1517. /** @override **/
  1518. ;
  1519. _proto.formatOffset = function formatOffset$1(ts, format) {
  1520. return formatOffset(this.offset(ts), format);
  1521. }
  1522. /** @override **/
  1523. ;
  1524. _proto.offset = function offset(ts) {
  1525. var date = new Date(ts);
  1526. if (isNaN(date)) return NaN;
  1527. var dtf = makeDTF(this.name),
  1528. _ref2 = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date),
  1529. year = _ref2[0],
  1530. month = _ref2[1],
  1531. day = _ref2[2],
  1532. hour = _ref2[3],
  1533. minute = _ref2[4],
  1534. second = _ref2[5],
  1535. adjustedHour = hour === 24 ? 0 : hour;
  1536. var asUTC = objToLocalTS({
  1537. year: year,
  1538. month: month,
  1539. day: day,
  1540. hour: adjustedHour,
  1541. minute: minute,
  1542. second: second,
  1543. millisecond: 0
  1544. });
  1545. var asTS = +date;
  1546. var over = asTS % 1000;
  1547. asTS -= over >= 0 ? over : 1000 + over;
  1548. return (asUTC - asTS) / (60 * 1000);
  1549. }
  1550. /** @override **/
  1551. ;
  1552. _proto.equals = function equals(otherZone) {
  1553. return otherZone.type === "iana" && otherZone.name === this.name;
  1554. }
  1555. /** @override **/
  1556. ;
  1557. _createClass(IANAZone, [{
  1558. key: "type",
  1559. get: function get() {
  1560. return "iana";
  1561. }
  1562. /** @override **/
  1563. }, {
  1564. key: "name",
  1565. get: function get() {
  1566. return this.zoneName;
  1567. }
  1568. /** @override **/
  1569. }, {
  1570. key: "universal",
  1571. get: function get() {
  1572. return false;
  1573. }
  1574. }, {
  1575. key: "isValid",
  1576. get: function get() {
  1577. return this.valid;
  1578. }
  1579. }]);
  1580. return IANAZone;
  1581. }(Zone);
  1582. var singleton$1 = null;
  1583. /**
  1584. * A zone with a fixed offset (meaning no DST)
  1585. * @implements {Zone}
  1586. */
  1587. var FixedOffsetZone = /*#__PURE__*/function (_Zone) {
  1588. _inheritsLoose(FixedOffsetZone, _Zone);
  1589. /**
  1590. * Get an instance with a specified offset
  1591. * @param {number} offset - The offset in minutes
  1592. * @return {FixedOffsetZone}
  1593. */
  1594. FixedOffsetZone.instance = function instance(offset) {
  1595. return offset === 0 ? FixedOffsetZone.utcInstance : new FixedOffsetZone(offset);
  1596. }
  1597. /**
  1598. * Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6"
  1599. * @param {string} s - The offset string to parse
  1600. * @example FixedOffsetZone.parseSpecifier("UTC+6")
  1601. * @example FixedOffsetZone.parseSpecifier("UTC+06")
  1602. * @example FixedOffsetZone.parseSpecifier("UTC-6:00")
  1603. * @return {FixedOffsetZone}
  1604. */
  1605. ;
  1606. FixedOffsetZone.parseSpecifier = function parseSpecifier(s) {
  1607. if (s) {
  1608. var r = s.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
  1609. if (r) {
  1610. return new FixedOffsetZone(signedOffset(r[1], r[2]));
  1611. }
  1612. }
  1613. return null;
  1614. };
  1615. _createClass(FixedOffsetZone, null, [{
  1616. key: "utcInstance",
  1617. /**
  1618. * Get a singleton instance of UTC
  1619. * @return {FixedOffsetZone}
  1620. */
  1621. get: function get() {
  1622. if (singleton$1 === null) {
  1623. singleton$1 = new FixedOffsetZone(0);
  1624. }
  1625. return singleton$1;
  1626. }
  1627. }]);
  1628. function FixedOffsetZone(offset) {
  1629. var _this;
  1630. _this = _Zone.call(this) || this;
  1631. /** @private **/
  1632. _this.fixed = offset;
  1633. return _this;
  1634. }
  1635. /** @override **/
  1636. var _proto = FixedOffsetZone.prototype;
  1637. /** @override **/
  1638. _proto.offsetName = function offsetName() {
  1639. return this.name;
  1640. }
  1641. /** @override **/
  1642. ;
  1643. _proto.formatOffset = function formatOffset$1(ts, format) {
  1644. return formatOffset(this.fixed, format);
  1645. }
  1646. /** @override **/
  1647. ;
  1648. /** @override **/
  1649. _proto.offset = function offset() {
  1650. return this.fixed;
  1651. }
  1652. /** @override **/
  1653. ;
  1654. _proto.equals = function equals(otherZone) {
  1655. return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
  1656. }
  1657. /** @override **/
  1658. ;
  1659. _createClass(FixedOffsetZone, [{
  1660. key: "type",
  1661. get: function get() {
  1662. return "fixed";
  1663. }
  1664. /** @override **/
  1665. }, {
  1666. key: "name",
  1667. get: function get() {
  1668. return this.fixed === 0 ? "UTC" : "UTC" + formatOffset(this.fixed, "narrow");
  1669. }
  1670. }, {
  1671. key: "universal",
  1672. get: function get() {
  1673. return true;
  1674. }
  1675. }, {
  1676. key: "isValid",
  1677. get: function get() {
  1678. return true;
  1679. }
  1680. }]);
  1681. return FixedOffsetZone;
  1682. }(Zone);
  1683. /**
  1684. * A zone that failed to parse. You should never need to instantiate this.
  1685. * @implements {Zone}
  1686. */
  1687. var InvalidZone = /*#__PURE__*/function (_Zone) {
  1688. _inheritsLoose(InvalidZone, _Zone);
  1689. function InvalidZone(zoneName) {
  1690. var _this;
  1691. _this = _Zone.call(this) || this;
  1692. /** @private */
  1693. _this.zoneName = zoneName;
  1694. return _this;
  1695. }
  1696. /** @override **/
  1697. var _proto = InvalidZone.prototype;
  1698. /** @override **/
  1699. _proto.offsetName = function offsetName() {
  1700. return null;
  1701. }
  1702. /** @override **/
  1703. ;
  1704. _proto.formatOffset = function formatOffset() {
  1705. return "";
  1706. }
  1707. /** @override **/
  1708. ;
  1709. _proto.offset = function offset() {
  1710. return NaN;
  1711. }
  1712. /** @override **/
  1713. ;
  1714. _proto.equals = function equals() {
  1715. return false;
  1716. }
  1717. /** @override **/
  1718. ;
  1719. _createClass(InvalidZone, [{
  1720. key: "type",
  1721. get: function get() {
  1722. return "invalid";
  1723. }
  1724. /** @override **/
  1725. }, {
  1726. key: "name",
  1727. get: function get() {
  1728. return this.zoneName;
  1729. }
  1730. /** @override **/
  1731. }, {
  1732. key: "universal",
  1733. get: function get() {
  1734. return false;
  1735. }
  1736. }, {
  1737. key: "isValid",
  1738. get: function get() {
  1739. return false;
  1740. }
  1741. }]);
  1742. return InvalidZone;
  1743. }(Zone);
  1744. /**
  1745. * @private
  1746. */
  1747. function normalizeZone(input, defaultZone) {
  1748. var offset;
  1749. if (isUndefined(input) || input === null) {
  1750. return defaultZone;
  1751. } else if (input instanceof Zone) {
  1752. return input;
  1753. } else if (isString(input)) {
  1754. var lowered = input.toLowerCase();
  1755. if (lowered === "local") return defaultZone;else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance;else if ((offset = IANAZone.parseGMTOffset(input)) != null) {
  1756. // handle Etc/GMT-4, which V8 chokes on
  1757. return FixedOffsetZone.instance(offset);
  1758. } else if (IANAZone.isValidSpecifier(lowered)) return IANAZone.create(input);else return FixedOffsetZone.parseSpecifier(lowered) || new InvalidZone(input);
  1759. } else if (isNumber(input)) {
  1760. return FixedOffsetZone.instance(input);
  1761. } else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
  1762. // This is dumb, but the instanceof check above doesn't seem to really work
  1763. // so we're duck checking it
  1764. return input;
  1765. } else {
  1766. return new InvalidZone(input);
  1767. }
  1768. }
  1769. var now = function now() {
  1770. return Date.now();
  1771. },
  1772. defaultZone = null,
  1773. // not setting this directly to LocalZone.instance bc loading order issues
  1774. defaultLocale = null,
  1775. defaultNumberingSystem = null,
  1776. defaultOutputCalendar = null,
  1777. throwOnInvalid = false;
  1778. /**
  1779. * Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here.
  1780. */
  1781. var Settings = /*#__PURE__*/function () {
  1782. function Settings() {}
  1783. /**
  1784. * Reset Luxon's global caches. Should only be necessary in testing scenarios.
  1785. * @return {void}
  1786. */
  1787. Settings.resetCaches = function resetCaches() {
  1788. Locale.resetCache();
  1789. IANAZone.resetCache();
  1790. };
  1791. _createClass(Settings, null, [{
  1792. key: "now",
  1793. /**
  1794. * Get the callback for returning the current timestamp.
  1795. * @type {function}
  1796. */
  1797. get: function get() {
  1798. return now;
  1799. }
  1800. /**
  1801. * Set the callback for returning the current timestamp.
  1802. * The function should return a number, which will be interpreted as an Epoch millisecond count
  1803. * @type {function}
  1804. * @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
  1805. * @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
  1806. */
  1807. ,
  1808. set: function set(n) {
  1809. now = n;
  1810. }
  1811. /**
  1812. * Get the default time zone to create DateTimes in.
  1813. * @type {string}
  1814. */
  1815. }, {
  1816. key: "defaultZoneName",
  1817. get: function get() {
  1818. return Settings.defaultZone.name;
  1819. }
  1820. /**
  1821. * Set the default time zone to create DateTimes in. Does not affect existing instances.
  1822. * @type {string}
  1823. */
  1824. ,
  1825. set: function set(z) {
  1826. if (!z) {
  1827. defaultZone = null;
  1828. } else {
  1829. defaultZone = normalizeZone(z);
  1830. }
  1831. }
  1832. /**
  1833. * Get the default time zone object to create DateTimes in. Does not affect existing instances.
  1834. * @type {Zone}
  1835. */
  1836. }, {
  1837. key: "defaultZone",
  1838. get: function get() {
  1839. return defaultZone || LocalZone.instance;
  1840. }
  1841. /**
  1842. * Get the default locale to create DateTimes with. Does not affect existing instances.
  1843. * @type {string}
  1844. */
  1845. }, {
  1846. key: "defaultLocale",
  1847. get: function get() {
  1848. return defaultLocale;
  1849. }
  1850. /**
  1851. * Set the default locale to create DateTimes with. Does not affect existing instances.
  1852. * @type {string}
  1853. */
  1854. ,
  1855. set: function set(locale) {
  1856. defaultLocale = locale;
  1857. }
  1858. /**
  1859. * Get the default numbering system to create DateTimes with. Does not affect existing instances.
  1860. * @type {string}
  1861. */
  1862. }, {
  1863. key: "defaultNumberingSystem",
  1864. get: function get() {
  1865. return defaultNumberingSystem;
  1866. }
  1867. /**
  1868. * Set the default numbering system to create DateTimes with. Does not affect existing instances.
  1869. * @type {string}
  1870. */
  1871. ,
  1872. set: function set(numberingSystem) {
  1873. defaultNumberingSystem = numberingSystem;
  1874. }
  1875. /**
  1876. * Get the default output calendar to create DateTimes with. Does not affect existing instances.
  1877. * @type {string}
  1878. */
  1879. }, {
  1880. key: "defaultOutputCalendar",
  1881. get: function get() {
  1882. return defaultOutputCalendar;
  1883. }
  1884. /**
  1885. * Set the default output calendar to create DateTimes with. Does not affect existing instances.
  1886. * @type {string}
  1887. */
  1888. ,
  1889. set: function set(outputCalendar) {
  1890. defaultOutputCalendar = outputCalendar;
  1891. }
  1892. /**
  1893. * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  1894. * @type {boolean}
  1895. */
  1896. }, {
  1897. key: "throwOnInvalid",
  1898. get: function get() {
  1899. return throwOnInvalid;
  1900. }
  1901. /**
  1902. * Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  1903. * @type {boolean}
  1904. */
  1905. ,
  1906. set: function set(t) {
  1907. throwOnInvalid = t;
  1908. }
  1909. }]);
  1910. return Settings;
  1911. }();
  1912. var intlDTCache = {};
  1913. function getCachedDTF(locString, opts) {
  1914. if (opts === void 0) {
  1915. opts = {};
  1916. }
  1917. var key = JSON.stringify([locString, opts]);
  1918. var dtf = intlDTCache[key];
  1919. if (!dtf) {
  1920. dtf = new Intl.DateTimeFormat(locString, opts);
  1921. intlDTCache[key] = dtf;
  1922. }
  1923. return dtf;
  1924. }
  1925. var intlNumCache = {};
  1926. function getCachedINF(locString, opts) {
  1927. if (opts === void 0) {
  1928. opts = {};
  1929. }
  1930. var key = JSON.stringify([locString, opts]);
  1931. var inf = intlNumCache[key];
  1932. if (!inf) {
  1933. inf = new Intl.NumberFormat(locString, opts);
  1934. intlNumCache[key] = inf;
  1935. }
  1936. return inf;
  1937. }
  1938. var intlRelCache = {};
  1939. function getCachedRTF(locString, opts) {
  1940. if (opts === void 0) {
  1941. opts = {};
  1942. }
  1943. var _opts = opts,
  1944. base = _opts.base,
  1945. cacheKeyOpts = _objectWithoutPropertiesLoose(_opts, ["base"]); // exclude `base` from the options
  1946. var key = JSON.stringify([locString, cacheKeyOpts]);
  1947. var inf = intlRelCache[key];
  1948. if (!inf) {
  1949. inf = new Intl.RelativeTimeFormat(locString, opts);
  1950. intlRelCache[key] = inf;
  1951. }
  1952. return inf;
  1953. }
  1954. var sysLocaleCache = null;
  1955. function systemLocale() {
  1956. if (sysLocaleCache) {
  1957. return sysLocaleCache;
  1958. } else if (hasIntl()) {
  1959. var computedSys = new Intl.DateTimeFormat().resolvedOptions().locale; // node sometimes defaults to "und". Override that because that is dumb
  1960. sysLocaleCache = !computedSys || computedSys === "und" ? "en-US" : computedSys;
  1961. return sysLocaleCache;
  1962. } else {
  1963. sysLocaleCache = "en-US";
  1964. return sysLocaleCache;
  1965. }
  1966. }
  1967. function parseLocaleString(localeStr) {
  1968. // I really want to avoid writing a BCP 47 parser
  1969. // see, e.g. https://github.com/wooorm/bcp-47
  1970. // Instead, we'll do this:
  1971. // a) if the string has no -u extensions, just leave it alone
  1972. // b) if it does, use Intl to resolve everything
  1973. // c) if Intl fails, try again without the -u
  1974. var uIndex = localeStr.indexOf("-u-");
  1975. if (uIndex === -1) {
  1976. return [localeStr];
  1977. } else {
  1978. var options;
  1979. var smaller = localeStr.substring(0, uIndex);
  1980. try {
  1981. options = getCachedDTF(localeStr).resolvedOptions();
  1982. } catch (e) {
  1983. options = getCachedDTF(smaller).resolvedOptions();
  1984. }
  1985. var _options = options,
  1986. numberingSystem = _options.numberingSystem,
  1987. calendar = _options.calendar; // return the smaller one so that we can append the calendar and numbering overrides to it
  1988. return [smaller, numberingSystem, calendar];
  1989. }
  1990. }
  1991. function intlConfigString(localeStr, numberingSystem, outputCalendar) {
  1992. if (hasIntl()) {
  1993. if (outputCalendar || numberingSystem) {
  1994. localeStr += "-u";
  1995. if (outputCalendar) {
  1996. localeStr += "-ca-" + outputCalendar;
  1997. }
  1998. if (numberingSystem) {
  1999. localeStr += "-nu-" + numberingSystem;
  2000. }
  2001. return localeStr;
  2002. } else {
  2003. return localeStr;
  2004. }
  2005. } else {
  2006. return [];
  2007. }
  2008. }
  2009. function mapMonths(f) {
  2010. var ms = [];
  2011. for (var i = 1; i <= 12; i++) {
  2012. var dt = DateTime.utc(2016, i, 1);
  2013. ms.push(f(dt));
  2014. }
  2015. return ms;
  2016. }
  2017. function mapWeekdays(f) {
  2018. var ms = [];
  2019. for (var i = 1; i <= 7; i++) {
  2020. var dt = DateTime.utc(2016, 11, 13 + i);
  2021. ms.push(f(dt));
  2022. }
  2023. return ms;
  2024. }
  2025. function listStuff(loc, length, defaultOK, englishFn, intlFn) {
  2026. var mode = loc.listingMode(defaultOK);
  2027. if (mode === "error") {
  2028. return null;
  2029. } else if (mode === "en") {
  2030. return englishFn(length);
  2031. } else {
  2032. return intlFn(length);
  2033. }
  2034. }
  2035. function supportsFastNumbers(loc) {
  2036. if (loc.numberingSystem && loc.numberingSystem !== "latn") {
  2037. return false;
  2038. } else {
  2039. return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || hasIntl() && new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn";
  2040. }
  2041. }
  2042. /**
  2043. * @private
  2044. */
  2045. var PolyNumberFormatter = /*#__PURE__*/function () {
  2046. function PolyNumberFormatter(intl, forceSimple, opts) {
  2047. this.padTo = opts.padTo || 0;
  2048. this.floor = opts.floor || false;
  2049. if (!forceSimple && hasIntl()) {
  2050. var intlOpts = {
  2051. useGrouping: false
  2052. };
  2053. if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;
  2054. this.inf = getCachedINF(intl, intlOpts);
  2055. }
  2056. }
  2057. var _proto = PolyNumberFormatter.prototype;
  2058. _proto.format = function format(i) {
  2059. if (this.inf) {
  2060. var fixed = this.floor ? Math.floor(i) : i;
  2061. return this.inf.format(fixed);
  2062. } else {
  2063. // to match the browser's numberformatter defaults
  2064. var _fixed = this.floor ? Math.floor(i) : roundTo(i, 3);
  2065. return padStart(_fixed, this.padTo);
  2066. }
  2067. };
  2068. return PolyNumberFormatter;
  2069. }();
  2070. /**
  2071. * @private
  2072. */
  2073. var PolyDateFormatter = /*#__PURE__*/function () {
  2074. function PolyDateFormatter(dt, intl, opts) {
  2075. this.opts = opts;
  2076. this.hasIntl = hasIntl();
  2077. var z;
  2078. if (dt.zone.universal && this.hasIntl) {
  2079. // UTC-8 or Etc/UTC-8 are not part of tzdata, only Etc/GMT+8 and the like.
  2080. // That is why fixed-offset TZ is set to that unless it is:
  2081. // 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT.
  2082. // 2. Unsupported by the browser:
  2083. // - some do not support Etc/
  2084. // - < Etc/GMT-14, > Etc/GMT+12, and 30-minute or 45-minute offsets are not part of tzdata
  2085. var gmtOffset = -1 * (dt.offset / 60);
  2086. var offsetZ = gmtOffset >= 0 ? "Etc/GMT+" + gmtOffset : "Etc/GMT" + gmtOffset;
  2087. var isOffsetZoneSupported = IANAZone.isValidZone(offsetZ);
  2088. if (dt.offset !== 0 && isOffsetZoneSupported) {
  2089. z = offsetZ;
  2090. this.dt = dt;
  2091. } else {
  2092. // Not all fixed-offset zones like Etc/+4:30 are present in tzdata.
  2093. // So we have to make do. Two cases:
  2094. // 1. The format options tell us to show the zone. We can't do that, so the best
  2095. // we can do is format the date in UTC.
  2096. // 2. The format options don't tell us to show the zone. Then we can adjust them
  2097. // the time and tell the formatter to show it to us in UTC, so that the time is right
  2098. // and the bad zone doesn't show up.
  2099. z = "UTC";
  2100. if (opts.timeZoneName) {
  2101. this.dt = dt;
  2102. } else {
  2103. this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
  2104. }
  2105. }
  2106. } else if (dt.zone.type === "local") {
  2107. this.dt = dt;
  2108. } else {
  2109. this.dt = dt;
  2110. z = dt.zone.name;
  2111. }
  2112. if (this.hasIntl) {
  2113. var intlOpts = Object.assign({}, this.opts);
  2114. if (z) {
  2115. intlOpts.timeZone = z;
  2116. }
  2117. this.dtf = getCachedDTF(intl, intlOpts);
  2118. }
  2119. }
  2120. var _proto2 = PolyDateFormatter.prototype;
  2121. _proto2.format = function format() {
  2122. if (this.hasIntl) {
  2123. return this.dtf.format(this.dt.toJSDate());
  2124. } else {
  2125. var tokenFormat = formatString(this.opts),
  2126. loc = Locale.create("en-US");
  2127. return Formatter.create(loc).formatDateTimeFromString(this.dt, tokenFormat);
  2128. }
  2129. };
  2130. _proto2.formatToParts = function formatToParts() {
  2131. if (this.hasIntl && hasFormatToParts()) {
  2132. return this.dtf.formatToParts(this.dt.toJSDate());
  2133. } else {
  2134. // This is kind of a cop out. We actually could do this for English. However, we couldn't do it for intl strings
  2135. // and IMO it's too weird to have an uncanny valley like that
  2136. return [];
  2137. }
  2138. };
  2139. _proto2.resolvedOptions = function resolvedOptions() {
  2140. if (this.hasIntl) {
  2141. return this.dtf.resolvedOptions();
  2142. } else {
  2143. return {
  2144. locale: "en-US",
  2145. numberingSystem: "latn",
  2146. outputCalendar: "gregory"
  2147. };
  2148. }
  2149. };
  2150. return PolyDateFormatter;
  2151. }();
  2152. /**
  2153. * @private
  2154. */
  2155. var PolyRelFormatter = /*#__PURE__*/function () {
  2156. function PolyRelFormatter(intl, isEnglish, opts) {
  2157. this.opts = Object.assign({
  2158. style: "long"
  2159. }, opts);
  2160. if (!isEnglish && hasRelative()) {
  2161. this.rtf = getCachedRTF(intl, opts);
  2162. }
  2163. }
  2164. var _proto3 = PolyRelFormatter.prototype;
  2165. _proto3.format = function format(count, unit) {
  2166. if (this.rtf) {
  2167. return this.rtf.format(count, unit);
  2168. } else {
  2169. return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long");
  2170. }
  2171. };
  2172. _proto3.formatToParts = function formatToParts(count, unit) {
  2173. if (this.rtf) {
  2174. return this.rtf.formatToParts(count, unit);
  2175. } else {
  2176. return [];
  2177. }
  2178. };
  2179. return PolyRelFormatter;
  2180. }();
  2181. /**
  2182. * @private
  2183. */
  2184. var Locale = /*#__PURE__*/function () {
  2185. Locale.fromOpts = function fromOpts(opts) {
  2186. return Locale.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
  2187. };
  2188. Locale.create = function create(locale, numberingSystem, outputCalendar, defaultToEN) {
  2189. if (defaultToEN === void 0) {
  2190. defaultToEN = false;
  2191. }
  2192. var specifiedLocale = locale || Settings.defaultLocale,
  2193. // the system locale is useful for human readable strings but annoying for parsing/formatting known formats
  2194. localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale()),
  2195. numberingSystemR = numberingSystem || Settings.defaultNumberingSystem,
  2196. outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
  2197. return new Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
  2198. };
  2199. Locale.resetCache = function resetCache() {
  2200. sysLocaleCache = null;
  2201. intlDTCache = {};
  2202. intlNumCache = {};
  2203. intlRelCache = {};
  2204. };
  2205. Locale.fromObject = function fromObject(_temp) {
  2206. var _ref = _temp === void 0 ? {} : _temp,
  2207. locale = _ref.locale,
  2208. numberingSystem = _ref.numberingSystem,
  2209. outputCalendar = _ref.outputCalendar;
  2210. return Locale.create(locale, numberingSystem, outputCalendar);
  2211. };
  2212. function Locale(locale, numbering, outputCalendar, specifiedLocale) {
  2213. var _parseLocaleString = parseLocaleString(locale),
  2214. parsedLocale = _parseLocaleString[0],
  2215. parsedNumberingSystem = _parseLocaleString[1],
  2216. parsedOutputCalendar = _parseLocaleString[2];
  2217. this.locale = parsedLocale;
  2218. this.numberingSystem = numbering || parsedNumberingSystem || null;
  2219. this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
  2220. this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar);
  2221. this.weekdaysCache = {
  2222. format: {},
  2223. standalone: {}
  2224. };
  2225. this.monthsCache = {
  2226. format: {},
  2227. standalone: {}
  2228. };
  2229. this.meridiemCache = null;
  2230. this.eraCache = {};
  2231. this.specifiedLocale = specifiedLocale;
  2232. this.fastNumbersCached = null;
  2233. }
  2234. var _proto4 = Locale.prototype;
  2235. _proto4.listingMode = function listingMode(defaultOK) {
  2236. if (defaultOK === void 0) {
  2237. defaultOK = true;
  2238. }
  2239. var intl = hasIntl(),
  2240. hasFTP = intl && hasFormatToParts(),
  2241. isActuallyEn = this.isEnglish(),
  2242. hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
  2243. if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOK) {
  2244. return "error";
  2245. } else if (!hasFTP || isActuallyEn && hasNoWeirdness) {
  2246. return "en";
  2247. } else {
  2248. return "intl";
  2249. }
  2250. };
  2251. _proto4.clone = function clone(alts) {
  2252. if (!alts || Object.getOwnPropertyNames(alts).length === 0) {
  2253. return this;
  2254. } else {
  2255. return Locale.create(alts.locale || this.specifiedLocale, alts.numberingSystem || this.numberingSystem, alts.outputCalendar || this.outputCalendar, alts.defaultToEN || false);
  2256. }
  2257. };
  2258. _proto4.redefaultToEN = function redefaultToEN(alts) {
  2259. if (alts === void 0) {
  2260. alts = {};
  2261. }
  2262. return this.clone(Object.assign({}, alts, {
  2263. defaultToEN: true
  2264. }));
  2265. };
  2266. _proto4.redefaultToSystem = function redefaultToSystem(alts) {
  2267. if (alts === void 0) {
  2268. alts = {};
  2269. }
  2270. return this.clone(Object.assign({}, alts, {
  2271. defaultToEN: false
  2272. }));
  2273. };
  2274. _proto4.months = function months$1(length, format, defaultOK) {
  2275. var _this = this;
  2276. if (format === void 0) {
  2277. format = false;
  2278. }
  2279. if (defaultOK === void 0) {
  2280. defaultOK = true;
  2281. }
  2282. return listStuff(this, length, defaultOK, months, function () {
  2283. var intl = format ? {
  2284. month: length,
  2285. day: "numeric"
  2286. } : {
  2287. month: length
  2288. },
  2289. formatStr = format ? "format" : "standalone";
  2290. if (!_this.monthsCache[formatStr][length]) {
  2291. _this.monthsCache[formatStr][length] = mapMonths(function (dt) {
  2292. return _this.extract(dt, intl, "month");
  2293. });
  2294. }
  2295. return _this.monthsCache[formatStr][length];
  2296. });
  2297. };
  2298. _proto4.weekdays = function weekdays$1(length, format, defaultOK) {
  2299. var _this2 = this;
  2300. if (format === void 0) {
  2301. format = false;
  2302. }
  2303. if (defaultOK === void 0) {
  2304. defaultOK = true;
  2305. }
  2306. return listStuff(this, length, defaultOK, weekdays, function () {
  2307. var intl = format ? {
  2308. weekday: length,
  2309. year: "numeric",
  2310. month: "long",
  2311. day: "numeric"
  2312. } : {
  2313. weekday: length
  2314. },
  2315. formatStr = format ? "format" : "standalone";
  2316. if (!_this2.weekdaysCache[formatStr][length]) {
  2317. _this2.weekdaysCache[formatStr][length] = mapWeekdays(function (dt) {
  2318. return _this2.extract(dt, intl, "weekday");
  2319. });
  2320. }
  2321. return _this2.weekdaysCache[formatStr][length];
  2322. });
  2323. };
  2324. _proto4.meridiems = function meridiems$1(defaultOK) {
  2325. var _this3 = this;
  2326. if (defaultOK === void 0) {
  2327. defaultOK = true;
  2328. }
  2329. return listStuff(this, undefined, defaultOK, function () {
  2330. return meridiems;
  2331. }, function () {
  2332. // In theory there could be aribitrary day periods. We're gonna assume there are exactly two
  2333. // for AM and PM. This is probably wrong, but it's makes parsing way easier.
  2334. if (!_this3.meridiemCache) {
  2335. var intl = {
  2336. hour: "numeric",
  2337. hour12: true
  2338. };
  2339. _this3.meridiemCache = [DateTime.utc(2016, 11, 13, 9), DateTime.utc(2016, 11, 13, 19)].map(function (dt) {
  2340. return _this3.extract(dt, intl, "dayperiod");
  2341. });
  2342. }
  2343. return _this3.meridiemCache;
  2344. });
  2345. };
  2346. _proto4.eras = function eras$1(length, defaultOK) {
  2347. var _this4 = this;
  2348. if (defaultOK === void 0) {
  2349. defaultOK = true;
  2350. }
  2351. return listStuff(this, length, defaultOK, eras, function () {
  2352. var intl = {
  2353. era: length
  2354. }; // This is problematic. Different calendars are going to define eras totally differently. What I need is the minimum set of dates
  2355. // to definitely enumerate them.
  2356. if (!_this4.eraCache[length]) {
  2357. _this4.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map(function (dt) {
  2358. return _this4.extract(dt, intl, "era");
  2359. });
  2360. }
  2361. return _this4.eraCache[length];
  2362. });
  2363. };
  2364. _proto4.extract = function extract(dt, intlOpts, field) {
  2365. var df = this.dtFormatter(dt, intlOpts),
  2366. results = df.formatToParts(),
  2367. matching = results.find(function (m) {
  2368. return m.type.toLowerCase() === field;
  2369. });
  2370. return matching ? matching.value : null;
  2371. };
  2372. _proto4.numberFormatter = function numberFormatter(opts) {
  2373. if (opts === void 0) {
  2374. opts = {};
  2375. }
  2376. // this forcesimple option is never used (the only caller short-circuits on it, but it seems safer to leave)
  2377. // (in contrast, the rest of the condition is used heavily)
  2378. return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts);
  2379. };
  2380. _proto4.dtFormatter = function dtFormatter(dt, intlOpts) {
  2381. if (intlOpts === void 0) {
  2382. intlOpts = {};
  2383. }
  2384. return new PolyDateFormatter(dt, this.intl, intlOpts);
  2385. };
  2386. _proto4.relFormatter = function relFormatter(opts) {
  2387. if (opts === void 0) {
  2388. opts = {};
  2389. }
  2390. return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
  2391. };
  2392. _proto4.isEnglish = function isEnglish() {
  2393. return this.locale === "en" || this.locale.toLowerCase() === "en-us" || hasIntl() && new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
  2394. };
  2395. _proto4.equals = function equals(other) {
  2396. return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
  2397. };
  2398. _createClass(Locale, [{
  2399. key: "fastNumbers",
  2400. get: function get() {
  2401. if (this.fastNumbersCached == null) {
  2402. this.fastNumbersCached = supportsFastNumbers(this);
  2403. }
  2404. return this.fastNumbersCached;
  2405. }
  2406. }]);
  2407. return Locale;
  2408. }();
  2409. /*
  2410. * This file handles parsing for well-specified formats. Here's how it works:
  2411. * Two things go into parsing: a regex to match with and an extractor to take apart the groups in the match.
  2412. * An extractor is just a function that takes a regex match array and returns a { year: ..., month: ... } object
  2413. * parse() does the work of executing the regex and applying the extractor. It takes multiple regex/extractor pairs to try in sequence.
  2414. * Extractors can take a "cursor" representing the offset in the match to look at. This makes it easy to combine extractors.
  2415. * combineExtractors() does the work of combining them, keeping track of the cursor through multiple extractions.
  2416. * Some extractions are super dumb and simpleParse and fromStrings help DRY them.
  2417. */
  2418. function combineRegexes() {
  2419. for (var _len = arguments.length, regexes = new Array(_len), _key = 0; _key < _len; _key++) {
  2420. regexes[_key] = arguments[_key];
  2421. }
  2422. var full = regexes.reduce(function (f, r) {
  2423. return f + r.source;
  2424. }, "");
  2425. return RegExp("^" + full + "$");
  2426. }
  2427. function combineExtractors() {
  2428. for (var _len2 = arguments.length, extractors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  2429. extractors[_key2] = arguments[_key2];
  2430. }
  2431. return function (m) {
  2432. return extractors.reduce(function (_ref, ex) {
  2433. var mergedVals = _ref[0],
  2434. mergedZone = _ref[1],
  2435. cursor = _ref[2];
  2436. var _ex = ex(m, cursor),
  2437. val = _ex[0],
  2438. zone = _ex[1],
  2439. next = _ex[2];
  2440. return [Object.assign(mergedVals, val), mergedZone || zone, next];
  2441. }, [{}, null, 1]).slice(0, 2);
  2442. };
  2443. }
  2444. function parse(s) {
  2445. if (s == null) {
  2446. return [null, null];
  2447. }
  2448. for (var _len3 = arguments.length, patterns = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  2449. patterns[_key3 - 1] = arguments[_key3];
  2450. }
  2451. for (var _i = 0, _patterns = patterns; _i < _patterns.length; _i++) {
  2452. var _patterns$_i = _patterns[_i],
  2453. regex = _patterns$_i[0],
  2454. extractor = _patterns$_i[1];
  2455. var m = regex.exec(s);
  2456. if (m) {
  2457. return extractor(m);
  2458. }
  2459. }
  2460. return [null, null];
  2461. }
  2462. function simpleParse() {
  2463. for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  2464. keys[_key4] = arguments[_key4];
  2465. }
  2466. return function (match, cursor) {
  2467. var ret = {};
  2468. var i;
  2469. for (i = 0; i < keys.length; i++) {
  2470. ret[keys[i]] = parseInteger(match[cursor + i]);
  2471. }
  2472. return [ret, null, cursor + i];
  2473. };
  2474. } // ISO and SQL parsing
  2475. var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,
  2476. isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,
  2477. isoTimeRegex = RegExp("" + isoTimeBaseRegex.source + offsetRegex.source + "?"),
  2478. isoTimeExtensionRegex = RegExp("(?:T" + isoTimeRegex.source + ")?"),
  2479. isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,
  2480. isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/,
  2481. isoOrdinalRegex = /(\d{4})-?(\d{3})/,
  2482. extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay"),
  2483. extractISOOrdinalData = simpleParse("year", "ordinal"),
  2484. sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/,
  2485. // dumbed-down version of the ISO one
  2486. sqlTimeRegex = RegExp(isoTimeBaseRegex.source + " ?(?:" + offsetRegex.source + "|(" + ianaRegex.source + "))?"),
  2487. sqlTimeExtensionRegex = RegExp("(?: " + sqlTimeRegex.source + ")?");
  2488. function int(match, pos, fallback) {
  2489. var m = match[pos];
  2490. return isUndefined(m) ? fallback : parseInteger(m);
  2491. }
  2492. function extractISOYmd(match, cursor) {
  2493. var item = {
  2494. year: int(match, cursor),
  2495. month: int(match, cursor + 1, 1),
  2496. day: int(match, cursor + 2, 1)
  2497. };
  2498. return [item, null, cursor + 3];
  2499. }
  2500. function extractISOTime(match, cursor) {
  2501. var item = {
  2502. hours: int(match, cursor, 0),
  2503. minutes: int(match, cursor + 1, 0),
  2504. seconds: int(match, cursor + 2, 0),
  2505. milliseconds: parseMillis(match[cursor + 3])
  2506. };
  2507. return [item, null, cursor + 4];
  2508. }
  2509. function extractISOOffset(match, cursor) {
  2510. var local = !match[cursor] && !match[cursor + 1],
  2511. fullOffset = signedOffset(match[cursor + 1], match[cursor + 2]),
  2512. zone = local ? null : FixedOffsetZone.instance(fullOffset);
  2513. return [{}, zone, cursor + 3];
  2514. }
  2515. function extractIANAZone(match, cursor) {
  2516. var zone = match[cursor] ? IANAZone.create(match[cursor]) : null;
  2517. return [{}, zone, cursor + 1];
  2518. } // ISO time parsing
  2519. var isoTimeOnly = RegExp("^T?" + isoTimeBaseRegex.source + "$"); // ISO duration parsing
  2520. var isoDuration = /^-?P(?:(?:(-?\d{1,9})Y)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})W)?(?:(-?\d{1,9})D)?(?:T(?:(-?\d{1,9})H)?(?:(-?\d{1,9})M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/;
  2521. function extractISODuration(match) {
  2522. var s = match[0],
  2523. yearStr = match[1],
  2524. monthStr = match[2],
  2525. weekStr = match[3],
  2526. dayStr = match[4],
  2527. hourStr = match[5],
  2528. minuteStr = match[6],
  2529. secondStr = match[7],
  2530. millisecondsStr = match[8];
  2531. var hasNegativePrefix = s[0] === "-";
  2532. var negativeSeconds = secondStr && secondStr[0] === "-";
  2533. var maybeNegate = function maybeNegate(num, force) {
  2534. if (force === void 0) {
  2535. force = false;
  2536. }
  2537. return num !== undefined && (force || num && hasNegativePrefix) ? -num : num;
  2538. };
  2539. return [{
  2540. years: maybeNegate(parseInteger(yearStr)),
  2541. months: maybeNegate(parseInteger(monthStr)),
  2542. weeks: maybeNegate(parseInteger(weekStr)),
  2543. days: maybeNegate(parseInteger(dayStr)),
  2544. hours: maybeNegate(parseInteger(hourStr)),
  2545. minutes: maybeNegate(parseInteger(minuteStr)),
  2546. seconds: maybeNegate(parseInteger(secondStr), secondStr === "-0"),
  2547. milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
  2548. }];
  2549. } // These are a little braindead. EDT *should* tell us that we're in, say, America/New_York
  2550. // and not just that we're in -240 *right now*. But since I don't think these are used that often
  2551. // I'm just going to ignore that
  2552. var obsOffsets = {
  2553. GMT: 0,
  2554. EDT: -4 * 60,
  2555. EST: -5 * 60,
  2556. CDT: -5 * 60,
  2557. CST: -6 * 60,
  2558. MDT: -6 * 60,
  2559. MST: -7 * 60,
  2560. PDT: -7 * 60,
  2561. PST: -8 * 60
  2562. };
  2563. function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  2564. var result = {
  2565. year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr),
  2566. month: monthsShort.indexOf(monthStr) + 1,
  2567. day: parseInteger(dayStr),
  2568. hour: parseInteger(hourStr),
  2569. minute: parseInteger(minuteStr)
  2570. };
  2571. if (secondStr) result.second = parseInteger(secondStr);
  2572. if (weekdayStr) {
  2573. result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1;
  2574. }
  2575. return result;
  2576. } // RFC 2822/5322
  2577. var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
  2578. function extractRFC2822(match) {
  2579. var weekdayStr = match[1],
  2580. dayStr = match[2],
  2581. monthStr = match[3],
  2582. yearStr = match[4],
  2583. hourStr = match[5],
  2584. minuteStr = match[6],
  2585. secondStr = match[7],
  2586. obsOffset = match[8],
  2587. milOffset = match[9],
  2588. offHourStr = match[10],
  2589. offMinuteStr = match[11],
  2590. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2591. var offset;
  2592. if (obsOffset) {
  2593. offset = obsOffsets[obsOffset];
  2594. } else if (milOffset) {
  2595. offset = 0;
  2596. } else {
  2597. offset = signedOffset(offHourStr, offMinuteStr);
  2598. }
  2599. return [result, new FixedOffsetZone(offset)];
  2600. }
  2601. function preprocessRFC2822(s) {
  2602. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  2603. return s.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
  2604. } // http date
  2605. var rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,
  2606. rfc850 = /^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,
  2607. ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
  2608. function extractRFC1123Or850(match) {
  2609. var weekdayStr = match[1],
  2610. dayStr = match[2],
  2611. monthStr = match[3],
  2612. yearStr = match[4],
  2613. hourStr = match[5],
  2614. minuteStr = match[6],
  2615. secondStr = match[7],
  2616. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2617. return [result, FixedOffsetZone.utcInstance];
  2618. }
  2619. function extractASCII(match) {
  2620. var weekdayStr = match[1],
  2621. monthStr = match[2],
  2622. dayStr = match[3],
  2623. hourStr = match[4],
  2624. minuteStr = match[5],
  2625. secondStr = match[6],
  2626. yearStr = match[7],
  2627. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2628. return [result, FixedOffsetZone.utcInstance];
  2629. }
  2630. var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex);
  2631. var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex);
  2632. var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex);
  2633. var isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
  2634. var extractISOYmdTimeAndOffset = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset);
  2635. var extractISOWeekTimeAndOffset = combineExtractors(extractISOWeekData, extractISOTime, extractISOOffset);
  2636. var extractISOOrdinalDataAndTime = combineExtractors(extractISOOrdinalData, extractISOTime);
  2637. var extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
  2638. /**
  2639. * @private
  2640. */
  2641. function parseISODate(s) {
  2642. return parse(s, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDataAndTime], [isoTimeCombinedRegex, extractISOTimeAndOffset]);
  2643. }
  2644. function parseRFC2822Date(s) {
  2645. return parse(preprocessRFC2822(s), [rfc2822, extractRFC2822]);
  2646. }
  2647. function parseHTTPDate(s) {
  2648. return parse(s, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], [ascii, extractASCII]);
  2649. }
  2650. function parseISODuration(s) {
  2651. return parse(s, [isoDuration, extractISODuration]);
  2652. }
  2653. var extractISOTimeOnly = combineExtractors(extractISOTime);
  2654. function parseISOTimeOnly(s) {
  2655. return parse(s, [isoTimeOnly, extractISOTimeOnly]);
  2656. }
  2657. var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
  2658. var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
  2659. var extractISOYmdTimeOffsetAndIANAZone = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset, extractIANAZone);
  2660. var extractISOTimeOffsetAndIANAZone = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone);
  2661. function parseSQL(s) {
  2662. return parse(s, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeOffsetAndIANAZone], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]);
  2663. }
  2664. var INVALID = "Invalid Duration"; // unit conversion constants
  2665. var lowOrderMatrix = {
  2666. weeks: {
  2667. days: 7,
  2668. hours: 7 * 24,
  2669. minutes: 7 * 24 * 60,
  2670. seconds: 7 * 24 * 60 * 60,
  2671. milliseconds: 7 * 24 * 60 * 60 * 1000
  2672. },
  2673. days: {
  2674. hours: 24,
  2675. minutes: 24 * 60,
  2676. seconds: 24 * 60 * 60,
  2677. milliseconds: 24 * 60 * 60 * 1000
  2678. },
  2679. hours: {
  2680. minutes: 60,
  2681. seconds: 60 * 60,
  2682. milliseconds: 60 * 60 * 1000
  2683. },
  2684. minutes: {
  2685. seconds: 60,
  2686. milliseconds: 60 * 1000
  2687. },
  2688. seconds: {
  2689. milliseconds: 1000
  2690. }
  2691. },
  2692. casualMatrix = Object.assign({
  2693. years: {
  2694. quarters: 4,
  2695. months: 12,
  2696. weeks: 52,
  2697. days: 365,
  2698. hours: 365 * 24,
  2699. minutes: 365 * 24 * 60,
  2700. seconds: 365 * 24 * 60 * 60,
  2701. milliseconds: 365 * 24 * 60 * 60 * 1000
  2702. },
  2703. quarters: {
  2704. months: 3,
  2705. weeks: 13,
  2706. days: 91,
  2707. hours: 91 * 24,
  2708. minutes: 91 * 24 * 60,
  2709. seconds: 91 * 24 * 60 * 60,
  2710. milliseconds: 91 * 24 * 60 * 60 * 1000
  2711. },
  2712. months: {
  2713. weeks: 4,
  2714. days: 30,
  2715. hours: 30 * 24,
  2716. minutes: 30 * 24 * 60,
  2717. seconds: 30 * 24 * 60 * 60,
  2718. milliseconds: 30 * 24 * 60 * 60 * 1000
  2719. }
  2720. }, lowOrderMatrix),
  2721. daysInYearAccurate = 146097.0 / 400,
  2722. daysInMonthAccurate = 146097.0 / 4800,
  2723. accurateMatrix = Object.assign({
  2724. years: {
  2725. quarters: 4,
  2726. months: 12,
  2727. weeks: daysInYearAccurate / 7,
  2728. days: daysInYearAccurate,
  2729. hours: daysInYearAccurate * 24,
  2730. minutes: daysInYearAccurate * 24 * 60,
  2731. seconds: daysInYearAccurate * 24 * 60 * 60,
  2732. milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000
  2733. },
  2734. quarters: {
  2735. months: 3,
  2736. weeks: daysInYearAccurate / 28,
  2737. days: daysInYearAccurate / 4,
  2738. hours: daysInYearAccurate * 24 / 4,
  2739. minutes: daysInYearAccurate * 24 * 60 / 4,
  2740. seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
  2741. milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 / 4
  2742. },
  2743. months: {
  2744. weeks: daysInMonthAccurate / 7,
  2745. days: daysInMonthAccurate,
  2746. hours: daysInMonthAccurate * 24,
  2747. minutes: daysInMonthAccurate * 24 * 60,
  2748. seconds: daysInMonthAccurate * 24 * 60 * 60,
  2749. milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000
  2750. }
  2751. }, lowOrderMatrix); // units ordered by size
  2752. var orderedUnits = ["years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds"];
  2753. var reverseUnits = orderedUnits.slice(0).reverse(); // clone really means "create another instance just like this one, but with these changes"
  2754. function clone(dur, alts, clear) {
  2755. if (clear === void 0) {
  2756. clear = false;
  2757. }
  2758. // deep merge for vals
  2759. var conf = {
  2760. values: clear ? alts.values : Object.assign({}, dur.values, alts.values || {}),
  2761. loc: dur.loc.clone(alts.loc),
  2762. conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
  2763. };
  2764. return new Duration(conf);
  2765. }
  2766. function antiTrunc(n) {
  2767. return n < 0 ? Math.floor(n) : Math.ceil(n);
  2768. } // NB: mutates parameters
  2769. function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
  2770. var conv = matrix[toUnit][fromUnit],
  2771. raw = fromMap[fromUnit] / conv,
  2772. sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]),
  2773. // ok, so this is wild, but see the matrix in the tests
  2774. added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw);
  2775. toMap[toUnit] += added;
  2776. fromMap[fromUnit] -= added * conv;
  2777. } // NB: mutates parameters
  2778. function normalizeValues(matrix, vals) {
  2779. reverseUnits.reduce(function (previous, current) {
  2780. if (!isUndefined(vals[current])) {
  2781. if (previous) {
  2782. convert(matrix, vals, previous, vals, current);
  2783. }
  2784. return current;
  2785. } else {
  2786. return previous;
  2787. }
  2788. }, null);
  2789. }
  2790. /**
  2791. * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime.
  2792. *
  2793. * Here is a brief overview of commonly used methods and getters in Duration:
  2794. *
  2795. * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
  2796. * * **Unit values** See the {@link Duration.years}, {@link Duration.months}, {@link Duration.weeks}, {@link Duration.days}, {@link Duration.hours}, {@link Duration.minutes}, {@link Duration.seconds}, {@link Duration.milliseconds} accessors.
  2797. * * **Configuration** See {@link Duration.locale} and {@link Duration.numberingSystem} accessors.
  2798. * * **Transformation** To create new Durations out of old ones use {@link Duration.plus}, {@link Duration.minus}, {@link Duration.normalize}, {@link Duration.set}, {@link Duration.reconfigure}, {@link Duration.shiftTo}, and {@link Duration.negate}.
  2799. * * **Output** To convert the Duration into other representations, see {@link Duration.as}, {@link Duration.toISO}, {@link Duration.toFormat}, and {@link Duration.toJSON}
  2800. *
  2801. * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation.
  2802. */
  2803. var Duration = /*#__PURE__*/function () {
  2804. /**
  2805. * @private
  2806. */
  2807. function Duration(config) {
  2808. var accurate = config.conversionAccuracy === "longterm" || false;
  2809. /**
  2810. * @access private
  2811. */
  2812. this.values = config.values;
  2813. /**
  2814. * @access private
  2815. */
  2816. this.loc = config.loc || Locale.create();
  2817. /**
  2818. * @access private
  2819. */
  2820. this.conversionAccuracy = accurate ? "longterm" : "casual";
  2821. /**
  2822. * @access private
  2823. */
  2824. this.invalid = config.invalid || null;
  2825. /**
  2826. * @access private
  2827. */
  2828. this.matrix = accurate ? accurateMatrix : casualMatrix;
  2829. /**
  2830. * @access private
  2831. */
  2832. this.isLuxonDuration = true;
  2833. }
  2834. /**
  2835. * Create Duration from a number of milliseconds.
  2836. * @param {number} count of milliseconds
  2837. * @param {Object} opts - options for parsing
  2838. * @param {string} [opts.locale='en-US'] - the locale to use
  2839. * @param {string} opts.numberingSystem - the numbering system to use
  2840. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  2841. * @return {Duration}
  2842. */
  2843. Duration.fromMillis = function fromMillis(count, opts) {
  2844. return Duration.fromObject(Object.assign({
  2845. milliseconds: count
  2846. }, opts));
  2847. }
  2848. /**
  2849. * Create a Duration from a JavaScript object with keys like 'years' and 'hours.
  2850. * If this object is empty then a zero milliseconds duration is returned.
  2851. * @param {Object} obj - the object to create the DateTime from
  2852. * @param {number} obj.years
  2853. * @param {number} obj.quarters
  2854. * @param {number} obj.months
  2855. * @param {number} obj.weeks
  2856. * @param {number} obj.days
  2857. * @param {number} obj.hours
  2858. * @param {number} obj.minutes
  2859. * @param {number} obj.seconds
  2860. * @param {number} obj.milliseconds
  2861. * @param {string} [obj.locale='en-US'] - the locale to use
  2862. * @param {string} obj.numberingSystem - the numbering system to use
  2863. * @param {string} [obj.conversionAccuracy='casual'] - the conversion system to use
  2864. * @return {Duration}
  2865. */
  2866. ;
  2867. Duration.fromObject = function fromObject(obj) {
  2868. if (obj == null || typeof obj !== "object") {
  2869. throw new InvalidArgumentError("Duration.fromObject: argument expected to be an object, got " + (obj === null ? "null" : typeof obj));
  2870. }
  2871. return new Duration({
  2872. values: normalizeObject(obj, Duration.normalizeUnit, ["locale", "numberingSystem", "conversionAccuracy", "zone" // a bit of debt; it's super inconvenient internally not to be able to blindly pass this
  2873. ]),
  2874. loc: Locale.fromObject(obj),
  2875. conversionAccuracy: obj.conversionAccuracy
  2876. });
  2877. }
  2878. /**
  2879. * Create a Duration from an ISO 8601 duration string.
  2880. * @param {string} text - text to parse
  2881. * @param {Object} opts - options for parsing
  2882. * @param {string} [opts.locale='en-US'] - the locale to use
  2883. * @param {string} opts.numberingSystem - the numbering system to use
  2884. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  2885. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
  2886. * @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
  2887. * @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
  2888. * @example Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 }
  2889. * @return {Duration}
  2890. */
  2891. ;
  2892. Duration.fromISO = function fromISO(text, opts) {
  2893. var _parseISODuration = parseISODuration(text),
  2894. parsed = _parseISODuration[0];
  2895. if (parsed) {
  2896. var obj = Object.assign(parsed, opts);
  2897. return Duration.fromObject(obj);
  2898. } else {
  2899. return Duration.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601");
  2900. }
  2901. }
  2902. /**
  2903. * Create a Duration from an ISO 8601 time string.
  2904. * @param {string} text - text to parse
  2905. * @param {Object} opts - options for parsing
  2906. * @param {string} [opts.locale='en-US'] - the locale to use
  2907. * @param {string} opts.numberingSystem - the numbering system to use
  2908. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  2909. * @see https://en.wikipedia.org/wiki/ISO_8601#Times
  2910. * @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
  2911. * @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
  2912. * @example Duration.fromISOTime('T11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
  2913. * @example Duration.fromISOTime('1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
  2914. * @example Duration.fromISOTime('T1100').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
  2915. * @return {Duration}
  2916. */
  2917. ;
  2918. Duration.fromISOTime = function fromISOTime(text, opts) {
  2919. var _parseISOTimeOnly = parseISOTimeOnly(text),
  2920. parsed = _parseISOTimeOnly[0];
  2921. if (parsed) {
  2922. var obj = Object.assign(parsed, opts);
  2923. return Duration.fromObject(obj);
  2924. } else {
  2925. return Duration.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601");
  2926. }
  2927. }
  2928. /**
  2929. * Create an invalid Duration.
  2930. * @param {string} reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent
  2931. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  2932. * @return {Duration}
  2933. */
  2934. ;
  2935. Duration.invalid = function invalid(reason, explanation) {
  2936. if (explanation === void 0) {
  2937. explanation = null;
  2938. }
  2939. if (!reason) {
  2940. throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
  2941. }
  2942. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  2943. if (Settings.throwOnInvalid) {
  2944. throw new InvalidDurationError(invalid);
  2945. } else {
  2946. return new Duration({
  2947. invalid: invalid
  2948. });
  2949. }
  2950. }
  2951. /**
  2952. * @private
  2953. */
  2954. ;
  2955. Duration.normalizeUnit = function normalizeUnit(unit) {
  2956. var normalized = {
  2957. year: "years",
  2958. years: "years",
  2959. quarter: "quarters",
  2960. quarters: "quarters",
  2961. month: "months",
  2962. months: "months",
  2963. week: "weeks",
  2964. weeks: "weeks",
  2965. day: "days",
  2966. days: "days",
  2967. hour: "hours",
  2968. hours: "hours",
  2969. minute: "minutes",
  2970. minutes: "minutes",
  2971. second: "seconds",
  2972. seconds: "seconds",
  2973. millisecond: "milliseconds",
  2974. milliseconds: "milliseconds"
  2975. }[unit ? unit.toLowerCase() : unit];
  2976. if (!normalized) throw new InvalidUnitError(unit);
  2977. return normalized;
  2978. }
  2979. /**
  2980. * Check if an object is a Duration. Works across context boundaries
  2981. * @param {object} o
  2982. * @return {boolean}
  2983. */
  2984. ;
  2985. Duration.isDuration = function isDuration(o) {
  2986. return o && o.isLuxonDuration || false;
  2987. }
  2988. /**
  2989. * Get the locale of a Duration, such 'en-GB'
  2990. * @type {string}
  2991. */
  2992. ;
  2993. var _proto = Duration.prototype;
  2994. /**
  2995. * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens:
  2996. * * `S` for milliseconds
  2997. * * `s` for seconds
  2998. * * `m` for minutes
  2999. * * `h` for hours
  3000. * * `d` for days
  3001. * * `M` for months
  3002. * * `y` for years
  3003. * Notes:
  3004. * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits
  3005. * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Durations's conversion accuracy setting.
  3006. * @param {string} fmt - the format string
  3007. * @param {Object} opts - options
  3008. * @param {boolean} [opts.floor=true] - floor numerical values
  3009. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"
  3010. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"
  3011. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"
  3012. * @return {string}
  3013. */
  3014. _proto.toFormat = function toFormat(fmt, opts) {
  3015. if (opts === void 0) {
  3016. opts = {};
  3017. }
  3018. // reverse-compat since 1.2; we always round down now, never up, and we do it by default
  3019. var fmtOpts = Object.assign({}, opts, {
  3020. floor: opts.round !== false && opts.floor !== false
  3021. });
  3022. return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID;
  3023. }
  3024. /**
  3025. * Returns a JavaScript object with this Duration's values.
  3026. * @param opts - options for generating the object
  3027. * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
  3028. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
  3029. * @return {Object}
  3030. */
  3031. ;
  3032. _proto.toObject = function toObject(opts) {
  3033. if (opts === void 0) {
  3034. opts = {};
  3035. }
  3036. if (!this.isValid) return {};
  3037. var base = Object.assign({}, this.values);
  3038. if (opts.includeConfig) {
  3039. base.conversionAccuracy = this.conversionAccuracy;
  3040. base.numberingSystem = this.loc.numberingSystem;
  3041. base.locale = this.loc.locale;
  3042. }
  3043. return base;
  3044. }
  3045. /**
  3046. * Returns an ISO 8601-compliant string representation of this Duration.
  3047. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
  3048. * @example Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S'
  3049. * @example Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S'
  3050. * @example Duration.fromObject({ months: 5 }).toISO() //=> 'P5M'
  3051. * @example Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M'
  3052. * @example Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S'
  3053. * @return {string}
  3054. */
  3055. ;
  3056. _proto.toISO = function toISO() {
  3057. // we could use the formatter, but this is an easier way to get the minimum string
  3058. if (!this.isValid) return null;
  3059. var s = "P";
  3060. if (this.years !== 0) s += this.years + "Y";
  3061. if (this.months !== 0 || this.quarters !== 0) s += this.months + this.quarters * 3 + "M";
  3062. if (this.weeks !== 0) s += this.weeks + "W";
  3063. if (this.days !== 0) s += this.days + "D";
  3064. if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0) s += "T";
  3065. if (this.hours !== 0) s += this.hours + "H";
  3066. if (this.minutes !== 0) s += this.minutes + "M";
  3067. if (this.seconds !== 0 || this.milliseconds !== 0) // this will handle "floating point madness" by removing extra decimal places
  3068. // https://stackoverflow.com/questions/588004/is-floating-point-math-broken
  3069. s += roundTo(this.seconds + this.milliseconds / 1000, 3) + "S";
  3070. if (s === "P") s += "T0S";
  3071. return s;
  3072. }
  3073. /**
  3074. * Returns an ISO 8601-compliant string representation of this Duration, formatted as a time of day.
  3075. * Note that this will return null if the duration is invalid, negative, or equal to or greater than 24 hours.
  3076. * @see https://en.wikipedia.org/wiki/ISO_8601#Times
  3077. * @param {Object} opts - options
  3078. * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
  3079. * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
  3080. * @param {boolean} [opts.includePrefix=false] - include the `T` prefix
  3081. * @param {string} [opts.format='extended'] - choose between the basic and extended format
  3082. * @example Duration.fromObject({ hours: 11 }).toISOTime() //=> '11:00:00.000'
  3083. * @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressMilliseconds: true }) //=> '11:00:00'
  3084. * @example Duration.fromObject({ hours: 11 }).toISOTime({ suppressSeconds: true }) //=> '11:00'
  3085. * @example Duration.fromObject({ hours: 11 }).toISOTime({ includePrefix: true }) //=> 'T11:00:00.000'
  3086. * @example Duration.fromObject({ hours: 11 }).toISOTime({ format: 'basic' }) //=> '110000.000'
  3087. * @return {string}
  3088. */
  3089. ;
  3090. _proto.toISOTime = function toISOTime(opts) {
  3091. if (opts === void 0) {
  3092. opts = {};
  3093. }
  3094. if (!this.isValid) return null;
  3095. var millis = this.toMillis();
  3096. if (millis < 0 || millis >= 86400000) return null;
  3097. opts = Object.assign({
  3098. suppressMilliseconds: false,
  3099. suppressSeconds: false,
  3100. includePrefix: false,
  3101. format: "extended"
  3102. }, opts);
  3103. var value = this.shiftTo("hours", "minutes", "seconds", "milliseconds");
  3104. var fmt = opts.format === "basic" ? "hhmm" : "hh:mm";
  3105. if (!opts.suppressSeconds || value.seconds !== 0 || value.milliseconds !== 0) {
  3106. fmt += opts.format === "basic" ? "ss" : ":ss";
  3107. if (!opts.suppressMilliseconds || value.milliseconds !== 0) {
  3108. fmt += ".SSS";
  3109. }
  3110. }
  3111. var str = value.toFormat(fmt);
  3112. if (opts.includePrefix) {
  3113. str = "T" + str;
  3114. }
  3115. return str;
  3116. }
  3117. /**
  3118. * Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
  3119. * @return {string}
  3120. */
  3121. ;
  3122. _proto.toJSON = function toJSON() {
  3123. return this.toISO();
  3124. }
  3125. /**
  3126. * Returns an ISO 8601 representation of this Duration appropriate for use in debugging.
  3127. * @return {string}
  3128. */
  3129. ;
  3130. _proto.toString = function toString() {
  3131. return this.toISO();
  3132. }
  3133. /**
  3134. * Returns an milliseconds value of this Duration.
  3135. * @return {number}
  3136. */
  3137. ;
  3138. _proto.toMillis = function toMillis() {
  3139. return this.as("milliseconds");
  3140. }
  3141. /**
  3142. * Returns an milliseconds value of this Duration. Alias of {@link toMillis}
  3143. * @return {number}
  3144. */
  3145. ;
  3146. _proto.valueOf = function valueOf() {
  3147. return this.toMillis();
  3148. }
  3149. /**
  3150. * Make this Duration longer by the specified amount. Return a newly-constructed Duration.
  3151. * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  3152. * @return {Duration}
  3153. */
  3154. ;
  3155. _proto.plus = function plus(duration) {
  3156. if (!this.isValid) return this;
  3157. var dur = friendlyDuration(duration),
  3158. result = {};
  3159. for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits), _step; !(_step = _iterator()).done;) {
  3160. var k = _step.value;
  3161. if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
  3162. result[k] = dur.get(k) + this.get(k);
  3163. }
  3164. }
  3165. return clone(this, {
  3166. values: result
  3167. }, true);
  3168. }
  3169. /**
  3170. * Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
  3171. * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  3172. * @return {Duration}
  3173. */
  3174. ;
  3175. _proto.minus = function minus(duration) {
  3176. if (!this.isValid) return this;
  3177. var dur = friendlyDuration(duration);
  3178. return this.plus(dur.negate());
  3179. }
  3180. /**
  3181. * Scale this Duration by the specified amount. Return a newly-constructed Duration.
  3182. * @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
  3183. * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }
  3184. * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
  3185. * @return {Duration}
  3186. */
  3187. ;
  3188. _proto.mapUnits = function mapUnits(fn) {
  3189. if (!this.isValid) return this;
  3190. var result = {};
  3191. for (var _i = 0, _Object$keys = Object.keys(this.values); _i < _Object$keys.length; _i++) {
  3192. var k = _Object$keys[_i];
  3193. result[k] = asNumber(fn(this.values[k], k));
  3194. }
  3195. return clone(this, {
  3196. values: result
  3197. }, true);
  3198. }
  3199. /**
  3200. * Get the value of unit.
  3201. * @param {string} unit - a unit such as 'minute' or 'day'
  3202. * @example Duration.fromObject({years: 2, days: 3}).get('years') //=> 2
  3203. * @example Duration.fromObject({years: 2, days: 3}).get('months') //=> 0
  3204. * @example Duration.fromObject({years: 2, days: 3}).get('days') //=> 3
  3205. * @return {number}
  3206. */
  3207. ;
  3208. _proto.get = function get(unit) {
  3209. return this[Duration.normalizeUnit(unit)];
  3210. }
  3211. /**
  3212. * "Set" the values of specified units. Return a newly-constructed Duration.
  3213. * @param {Object} values - a mapping of units to numbers
  3214. * @example dur.set({ years: 2017 })
  3215. * @example dur.set({ hours: 8, minutes: 30 })
  3216. * @return {Duration}
  3217. */
  3218. ;
  3219. _proto.set = function set(values) {
  3220. if (!this.isValid) return this;
  3221. var mixed = Object.assign(this.values, normalizeObject(values, Duration.normalizeUnit, []));
  3222. return clone(this, {
  3223. values: mixed
  3224. });
  3225. }
  3226. /**
  3227. * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration.
  3228. * @example dur.reconfigure({ locale: 'en-GB' })
  3229. * @return {Duration}
  3230. */
  3231. ;
  3232. _proto.reconfigure = function reconfigure(_temp) {
  3233. var _ref = _temp === void 0 ? {} : _temp,
  3234. locale = _ref.locale,
  3235. numberingSystem = _ref.numberingSystem,
  3236. conversionAccuracy = _ref.conversionAccuracy;
  3237. var loc = this.loc.clone({
  3238. locale: locale,
  3239. numberingSystem: numberingSystem
  3240. }),
  3241. opts = {
  3242. loc: loc
  3243. };
  3244. if (conversionAccuracy) {
  3245. opts.conversionAccuracy = conversionAccuracy;
  3246. }
  3247. return clone(this, opts);
  3248. }
  3249. /**
  3250. * Return the length of the duration in the specified unit.
  3251. * @param {string} unit - a unit such as 'minutes' or 'days'
  3252. * @example Duration.fromObject({years: 1}).as('days') //=> 365
  3253. * @example Duration.fromObject({years: 1}).as('months') //=> 12
  3254. * @example Duration.fromObject({hours: 60}).as('days') //=> 2.5
  3255. * @return {number}
  3256. */
  3257. ;
  3258. _proto.as = function as(unit) {
  3259. return this.isValid ? this.shiftTo(unit).get(unit) : NaN;
  3260. }
  3261. /**
  3262. * Reduce this Duration to its canonical representation in its current units.
  3263. * @example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }
  3264. * @example Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }
  3265. * @return {Duration}
  3266. */
  3267. ;
  3268. _proto.normalize = function normalize() {
  3269. if (!this.isValid) return this;
  3270. var vals = this.toObject();
  3271. normalizeValues(this.matrix, vals);
  3272. return clone(this, {
  3273. values: vals
  3274. }, true);
  3275. }
  3276. /**
  3277. * Convert this Duration into its representation in a different set of units.
  3278. * @example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }
  3279. * @return {Duration}
  3280. */
  3281. ;
  3282. _proto.shiftTo = function shiftTo() {
  3283. for (var _len = arguments.length, units = new Array(_len), _key = 0; _key < _len; _key++) {
  3284. units[_key] = arguments[_key];
  3285. }
  3286. if (!this.isValid) return this;
  3287. if (units.length === 0) {
  3288. return this;
  3289. }
  3290. units = units.map(function (u) {
  3291. return Duration.normalizeUnit(u);
  3292. });
  3293. var built = {},
  3294. accumulated = {},
  3295. vals = this.toObject();
  3296. var lastUnit;
  3297. for (var _iterator2 = _createForOfIteratorHelperLoose(orderedUnits), _step2; !(_step2 = _iterator2()).done;) {
  3298. var k = _step2.value;
  3299. if (units.indexOf(k) >= 0) {
  3300. lastUnit = k;
  3301. var own = 0; // anything we haven't boiled down yet should get boiled to this unit
  3302. for (var ak in accumulated) {
  3303. own += this.matrix[ak][k] * accumulated[ak];
  3304. accumulated[ak] = 0;
  3305. } // plus anything that's already in this unit
  3306. if (isNumber(vals[k])) {
  3307. own += vals[k];
  3308. }
  3309. var i = Math.trunc(own);
  3310. built[k] = i;
  3311. accumulated[k] = own - i; // we'd like to absorb these fractions in another unit
  3312. // plus anything further down the chain that should be rolled up in to this
  3313. for (var down in vals) {
  3314. if (orderedUnits.indexOf(down) > orderedUnits.indexOf(k)) {
  3315. convert(this.matrix, vals, down, built, k);
  3316. }
  3317. } // otherwise, keep it in the wings to boil it later
  3318. } else if (isNumber(vals[k])) {
  3319. accumulated[k] = vals[k];
  3320. }
  3321. } // anything leftover becomes the decimal for the last unit
  3322. // lastUnit must be defined since units is not empty
  3323. for (var key in accumulated) {
  3324. if (accumulated[key] !== 0) {
  3325. built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key];
  3326. }
  3327. }
  3328. return clone(this, {
  3329. values: built
  3330. }, true).normalize();
  3331. }
  3332. /**
  3333. * Return the negative of this Duration.
  3334. * @example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }
  3335. * @return {Duration}
  3336. */
  3337. ;
  3338. _proto.negate = function negate() {
  3339. if (!this.isValid) return this;
  3340. var negated = {};
  3341. for (var _i2 = 0, _Object$keys2 = Object.keys(this.values); _i2 < _Object$keys2.length; _i2++) {
  3342. var k = _Object$keys2[_i2];
  3343. negated[k] = -this.values[k];
  3344. }
  3345. return clone(this, {
  3346. values: negated
  3347. }, true);
  3348. }
  3349. /**
  3350. * Get the years.
  3351. * @type {number}
  3352. */
  3353. ;
  3354. /**
  3355. * Equality check
  3356. * Two Durations are equal iff they have the same units and the same values for each unit.
  3357. * @param {Duration} other
  3358. * @return {boolean}
  3359. */
  3360. _proto.equals = function equals(other) {
  3361. if (!this.isValid || !other.isValid) {
  3362. return false;
  3363. }
  3364. if (!this.loc.equals(other.loc)) {
  3365. return false;
  3366. }
  3367. function eq(v1, v2) {
  3368. // Consider 0 and undefined as equal
  3369. if (v1 === undefined || v1 === 0) return v2 === undefined || v2 === 0;
  3370. return v1 === v2;
  3371. }
  3372. for (var _iterator3 = _createForOfIteratorHelperLoose(orderedUnits), _step3; !(_step3 = _iterator3()).done;) {
  3373. var u = _step3.value;
  3374. if (!eq(this.values[u], other.values[u])) {
  3375. return false;
  3376. }
  3377. }
  3378. return true;
  3379. };
  3380. _createClass(Duration, [{
  3381. key: "locale",
  3382. get: function get() {
  3383. return this.isValid ? this.loc.locale : null;
  3384. }
  3385. /**
  3386. * Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration
  3387. *
  3388. * @type {string}
  3389. */
  3390. }, {
  3391. key: "numberingSystem",
  3392. get: function get() {
  3393. return this.isValid ? this.loc.numberingSystem : null;
  3394. }
  3395. }, {
  3396. key: "years",
  3397. get: function get() {
  3398. return this.isValid ? this.values.years || 0 : NaN;
  3399. }
  3400. /**
  3401. * Get the quarters.
  3402. * @type {number}
  3403. */
  3404. }, {
  3405. key: "quarters",
  3406. get: function get() {
  3407. return this.isValid ? this.values.quarters || 0 : NaN;
  3408. }
  3409. /**
  3410. * Get the months.
  3411. * @type {number}
  3412. */
  3413. }, {
  3414. key: "months",
  3415. get: function get() {
  3416. return this.isValid ? this.values.months || 0 : NaN;
  3417. }
  3418. /**
  3419. * Get the weeks
  3420. * @type {number}
  3421. */
  3422. }, {
  3423. key: "weeks",
  3424. get: function get() {
  3425. return this.isValid ? this.values.weeks || 0 : NaN;
  3426. }
  3427. /**
  3428. * Get the days.
  3429. * @type {number}
  3430. */
  3431. }, {
  3432. key: "days",
  3433. get: function get() {
  3434. return this.isValid ? this.values.days || 0 : NaN;
  3435. }
  3436. /**
  3437. * Get the hours.
  3438. * @type {number}
  3439. */
  3440. }, {
  3441. key: "hours",
  3442. get: function get() {
  3443. return this.isValid ? this.values.hours || 0 : NaN;
  3444. }
  3445. /**
  3446. * Get the minutes.
  3447. * @type {number}
  3448. */
  3449. }, {
  3450. key: "minutes",
  3451. get: function get() {
  3452. return this.isValid ? this.values.minutes || 0 : NaN;
  3453. }
  3454. /**
  3455. * Get the seconds.
  3456. * @return {number}
  3457. */
  3458. }, {
  3459. key: "seconds",
  3460. get: function get() {
  3461. return this.isValid ? this.values.seconds || 0 : NaN;
  3462. }
  3463. /**
  3464. * Get the milliseconds.
  3465. * @return {number}
  3466. */
  3467. }, {
  3468. key: "milliseconds",
  3469. get: function get() {
  3470. return this.isValid ? this.values.milliseconds || 0 : NaN;
  3471. }
  3472. /**
  3473. * Returns whether the Duration is invalid. Invalid durations are returned by diff operations
  3474. * on invalid DateTimes or Intervals.
  3475. * @return {boolean}
  3476. */
  3477. }, {
  3478. key: "isValid",
  3479. get: function get() {
  3480. return this.invalid === null;
  3481. }
  3482. /**
  3483. * Returns an error code if this Duration became invalid, or null if the Duration is valid
  3484. * @return {string}
  3485. */
  3486. }, {
  3487. key: "invalidReason",
  3488. get: function get() {
  3489. return this.invalid ? this.invalid.reason : null;
  3490. }
  3491. /**
  3492. * Returns an explanation of why this Duration became invalid, or null if the Duration is valid
  3493. * @type {string}
  3494. */
  3495. }, {
  3496. key: "invalidExplanation",
  3497. get: function get() {
  3498. return this.invalid ? this.invalid.explanation : null;
  3499. }
  3500. }]);
  3501. return Duration;
  3502. }();
  3503. function friendlyDuration(durationish) {
  3504. if (isNumber(durationish)) {
  3505. return Duration.fromMillis(durationish);
  3506. } else if (Duration.isDuration(durationish)) {
  3507. return durationish;
  3508. } else if (typeof durationish === "object") {
  3509. return Duration.fromObject(durationish);
  3510. } else {
  3511. throw new InvalidArgumentError("Unknown duration argument " + durationish + " of type " + typeof durationish);
  3512. }
  3513. }
  3514. var INVALID$1 = "Invalid Interval"; // checks if the start is equal to or before the end
  3515. function validateStartEnd(start, end) {
  3516. if (!start || !start.isValid) {
  3517. return Interval.invalid("missing or invalid start");
  3518. } else if (!end || !end.isValid) {
  3519. return Interval.invalid("missing or invalid end");
  3520. } else if (end < start) {
  3521. return Interval.invalid("end before start", "The end of an interval must be after its start, but you had start=" + start.toISO() + " and end=" + end.toISO());
  3522. } else {
  3523. return null;
  3524. }
  3525. }
  3526. /**
  3527. * An Interval object represents a half-open interval of time, where each endpoint is a {@link DateTime}. Conceptually, it's a container for those two endpoints, accompanied by methods for creating, parsing, interrogating, comparing, transforming, and formatting them.
  3528. *
  3529. * Here is a brief overview of the most commonly used methods and getters in Interval:
  3530. *
  3531. * * **Creation** To create an Interval, use {@link fromDateTimes}, {@link after}, {@link before}, or {@link fromISO}.
  3532. * * **Accessors** Use {@link start} and {@link end} to get the start and end.
  3533. * * **Interrogation** To analyze the Interval, use {@link count}, {@link length}, {@link hasSame}, {@link contains}, {@link isAfter}, or {@link isBefore}.
  3534. * * **Transformation** To create other Intervals out of this one, use {@link set}, {@link splitAt}, {@link splitBy}, {@link divideEqually}, {@link merge}, {@link xor}, {@link union}, {@link intersection}, or {@link difference}.
  3535. * * **Comparison** To compare this Interval to another one, use {@link equals}, {@link overlaps}, {@link abutsStart}, {@link abutsEnd}, {@link engulfs}.
  3536. * * **Output** To convert the Interval into other representations, see {@link toString}, {@link toISO}, {@link toISODate}, {@link toISOTime}, {@link toFormat}, and {@link toDuration}.
  3537. */
  3538. var Interval = /*#__PURE__*/function () {
  3539. /**
  3540. * @private
  3541. */
  3542. function Interval(config) {
  3543. /**
  3544. * @access private
  3545. */
  3546. this.s = config.start;
  3547. /**
  3548. * @access private
  3549. */
  3550. this.e = config.end;
  3551. /**
  3552. * @access private
  3553. */
  3554. this.invalid = config.invalid || null;
  3555. /**
  3556. * @access private
  3557. */
  3558. this.isLuxonInterval = true;
  3559. }
  3560. /**
  3561. * Create an invalid Interval.
  3562. * @param {string} reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent
  3563. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  3564. * @return {Interval}
  3565. */
  3566. Interval.invalid = function invalid(reason, explanation) {
  3567. if (explanation === void 0) {
  3568. explanation = null;
  3569. }
  3570. if (!reason) {
  3571. throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
  3572. }
  3573. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  3574. if (Settings.throwOnInvalid) {
  3575. throw new InvalidIntervalError(invalid);
  3576. } else {
  3577. return new Interval({
  3578. invalid: invalid
  3579. });
  3580. }
  3581. }
  3582. /**
  3583. * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end.
  3584. * @param {DateTime|Date|Object} start
  3585. * @param {DateTime|Date|Object} end
  3586. * @return {Interval}
  3587. */
  3588. ;
  3589. Interval.fromDateTimes = function fromDateTimes(start, end) {
  3590. var builtStart = friendlyDateTime(start),
  3591. builtEnd = friendlyDateTime(end);
  3592. var validateError = validateStartEnd(builtStart, builtEnd);
  3593. if (validateError == null) {
  3594. return new Interval({
  3595. start: builtStart,
  3596. end: builtEnd
  3597. });
  3598. } else {
  3599. return validateError;
  3600. }
  3601. }
  3602. /**
  3603. * Create an Interval from a start DateTime and a Duration to extend to.
  3604. * @param {DateTime|Date|Object} start
  3605. * @param {Duration|Object|number} duration - the length of the Interval.
  3606. * @return {Interval}
  3607. */
  3608. ;
  3609. Interval.after = function after(start, duration) {
  3610. var dur = friendlyDuration(duration),
  3611. dt = friendlyDateTime(start);
  3612. return Interval.fromDateTimes(dt, dt.plus(dur));
  3613. }
  3614. /**
  3615. * Create an Interval from an end DateTime and a Duration to extend backwards to.
  3616. * @param {DateTime|Date|Object} end
  3617. * @param {Duration|Object|number} duration - the length of the Interval.
  3618. * @return {Interval}
  3619. */
  3620. ;
  3621. Interval.before = function before(end, duration) {
  3622. var dur = friendlyDuration(duration),
  3623. dt = friendlyDateTime(end);
  3624. return Interval.fromDateTimes(dt.minus(dur), dt);
  3625. }
  3626. /**
  3627. * Create an Interval from an ISO 8601 string.
  3628. * Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats.
  3629. * @param {string} text - the ISO string to parse
  3630. * @param {Object} [opts] - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO}
  3631. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  3632. * @return {Interval}
  3633. */
  3634. ;
  3635. Interval.fromISO = function fromISO(text, opts) {
  3636. var _split = (text || "").split("/", 2),
  3637. s = _split[0],
  3638. e = _split[1];
  3639. if (s && e) {
  3640. var start, startIsValid;
  3641. try {
  3642. start = DateTime.fromISO(s, opts);
  3643. startIsValid = start.isValid;
  3644. } catch (e) {
  3645. startIsValid = false;
  3646. }
  3647. var end, endIsValid;
  3648. try {
  3649. end = DateTime.fromISO(e, opts);
  3650. endIsValid = end.isValid;
  3651. } catch (e) {
  3652. endIsValid = false;
  3653. }
  3654. if (startIsValid && endIsValid) {
  3655. return Interval.fromDateTimes(start, end);
  3656. }
  3657. if (startIsValid) {
  3658. var dur = Duration.fromISO(e, opts);
  3659. if (dur.isValid) {
  3660. return Interval.after(start, dur);
  3661. }
  3662. } else if (endIsValid) {
  3663. var _dur = Duration.fromISO(s, opts);
  3664. if (_dur.isValid) {
  3665. return Interval.before(end, _dur);
  3666. }
  3667. }
  3668. }
  3669. return Interval.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601");
  3670. }
  3671. /**
  3672. * Check if an object is an Interval. Works across context boundaries
  3673. * @param {object} o
  3674. * @return {boolean}
  3675. */
  3676. ;
  3677. Interval.isInterval = function isInterval(o) {
  3678. return o && o.isLuxonInterval || false;
  3679. }
  3680. /**
  3681. * Returns the start of the Interval
  3682. * @type {DateTime}
  3683. */
  3684. ;
  3685. var _proto = Interval.prototype;
  3686. /**
  3687. * Returns the length of the Interval in the specified unit.
  3688. * @param {string} unit - the unit (such as 'hours' or 'days') to return the length in.
  3689. * @return {number}
  3690. */
  3691. _proto.length = function length(unit) {
  3692. if (unit === void 0) {
  3693. unit = "milliseconds";
  3694. }
  3695. return this.isValid ? this.toDuration.apply(this, [unit]).get(unit) : NaN;
  3696. }
  3697. /**
  3698. * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part.
  3699. * Unlike {@link length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
  3700. * asks 'what dates are included in this interval?', not 'how many days long is this interval?'
  3701. * @param {string} [unit='milliseconds'] - the unit of time to count.
  3702. * @return {number}
  3703. */
  3704. ;
  3705. _proto.count = function count(unit) {
  3706. if (unit === void 0) {
  3707. unit = "milliseconds";
  3708. }
  3709. if (!this.isValid) return NaN;
  3710. var start = this.start.startOf(unit),
  3711. end = this.end.startOf(unit);
  3712. return Math.floor(end.diff(start, unit).get(unit)) + 1;
  3713. }
  3714. /**
  3715. * Returns whether this Interval's start and end are both in the same unit of time
  3716. * @param {string} unit - the unit of time to check sameness on
  3717. * @return {boolean}
  3718. */
  3719. ;
  3720. _proto.hasSame = function hasSame(unit) {
  3721. return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
  3722. }
  3723. /**
  3724. * Return whether this Interval has the same start and end DateTimes.
  3725. * @return {boolean}
  3726. */
  3727. ;
  3728. _proto.isEmpty = function isEmpty() {
  3729. return this.s.valueOf() === this.e.valueOf();
  3730. }
  3731. /**
  3732. * Return whether this Interval's start is after the specified DateTime.
  3733. * @param {DateTime} dateTime
  3734. * @return {boolean}
  3735. */
  3736. ;
  3737. _proto.isAfter = function isAfter(dateTime) {
  3738. if (!this.isValid) return false;
  3739. return this.s > dateTime;
  3740. }
  3741. /**
  3742. * Return whether this Interval's end is before the specified DateTime.
  3743. * @param {DateTime} dateTime
  3744. * @return {boolean}
  3745. */
  3746. ;
  3747. _proto.isBefore = function isBefore(dateTime) {
  3748. if (!this.isValid) return false;
  3749. return this.e <= dateTime;
  3750. }
  3751. /**
  3752. * Return whether this Interval contains the specified DateTime.
  3753. * @param {DateTime} dateTime
  3754. * @return {boolean}
  3755. */
  3756. ;
  3757. _proto.contains = function contains(dateTime) {
  3758. if (!this.isValid) return false;
  3759. return this.s <= dateTime && this.e > dateTime;
  3760. }
  3761. /**
  3762. * "Sets" the start and/or end dates. Returns a newly-constructed Interval.
  3763. * @param {Object} values - the values to set
  3764. * @param {DateTime} values.start - the starting DateTime
  3765. * @param {DateTime} values.end - the ending DateTime
  3766. * @return {Interval}
  3767. */
  3768. ;
  3769. _proto.set = function set(_temp) {
  3770. var _ref = _temp === void 0 ? {} : _temp,
  3771. start = _ref.start,
  3772. end = _ref.end;
  3773. if (!this.isValid) return this;
  3774. return Interval.fromDateTimes(start || this.s, end || this.e);
  3775. }
  3776. /**
  3777. * Split this Interval at each of the specified DateTimes
  3778. * @param {...[DateTime]} dateTimes - the unit of time to count.
  3779. * @return {[Interval]}
  3780. */
  3781. ;
  3782. _proto.splitAt = function splitAt() {
  3783. var _this = this;
  3784. if (!this.isValid) return [];
  3785. for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
  3786. dateTimes[_key] = arguments[_key];
  3787. }
  3788. var sorted = dateTimes.map(friendlyDateTime).filter(function (d) {
  3789. return _this.contains(d);
  3790. }).sort(),
  3791. results = [];
  3792. var s = this.s,
  3793. i = 0;
  3794. while (s < this.e) {
  3795. var added = sorted[i] || this.e,
  3796. next = +added > +this.e ? this.e : added;
  3797. results.push(Interval.fromDateTimes(s, next));
  3798. s = next;
  3799. i += 1;
  3800. }
  3801. return results;
  3802. }
  3803. /**
  3804. * Split this Interval into smaller Intervals, each of the specified length.
  3805. * Left over time is grouped into a smaller interval
  3806. * @param {Duration|Object|number} duration - The length of each resulting interval.
  3807. * @return {[Interval]}
  3808. */
  3809. ;
  3810. _proto.splitBy = function splitBy(duration) {
  3811. var dur = friendlyDuration(duration);
  3812. if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
  3813. return [];
  3814. }
  3815. var s = this.s,
  3816. idx = 1,
  3817. next;
  3818. var results = [];
  3819. while (s < this.e) {
  3820. var added = this.start.plus(dur.mapUnits(function (x) {
  3821. return x * idx;
  3822. }));
  3823. next = +added > +this.e ? this.e : added;
  3824. results.push(Interval.fromDateTimes(s, next));
  3825. s = next;
  3826. idx += 1;
  3827. }
  3828. return results;
  3829. }
  3830. /**
  3831. * Split this Interval into the specified number of smaller intervals.
  3832. * @param {number} numberOfParts - The number of Intervals to divide the Interval into.
  3833. * @return {[Interval]}
  3834. */
  3835. ;
  3836. _proto.divideEqually = function divideEqually(numberOfParts) {
  3837. if (!this.isValid) return [];
  3838. return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
  3839. }
  3840. /**
  3841. * Return whether this Interval overlaps with the specified Interval
  3842. * @param {Interval} other
  3843. * @return {boolean}
  3844. */
  3845. ;
  3846. _proto.overlaps = function overlaps(other) {
  3847. return this.e > other.s && this.s < other.e;
  3848. }
  3849. /**
  3850. * Return whether this Interval's end is adjacent to the specified Interval's start.
  3851. * @param {Interval} other
  3852. * @return {boolean}
  3853. */
  3854. ;
  3855. _proto.abutsStart = function abutsStart(other) {
  3856. if (!this.isValid) return false;
  3857. return +this.e === +other.s;
  3858. }
  3859. /**
  3860. * Return whether this Interval's start is adjacent to the specified Interval's end.
  3861. * @param {Interval} other
  3862. * @return {boolean}
  3863. */
  3864. ;
  3865. _proto.abutsEnd = function abutsEnd(other) {
  3866. if (!this.isValid) return false;
  3867. return +other.e === +this.s;
  3868. }
  3869. /**
  3870. * Return whether this Interval engulfs the start and end of the specified Interval.
  3871. * @param {Interval} other
  3872. * @return {boolean}
  3873. */
  3874. ;
  3875. _proto.engulfs = function engulfs(other) {
  3876. if (!this.isValid) return false;
  3877. return this.s <= other.s && this.e >= other.e;
  3878. }
  3879. /**
  3880. * Return whether this Interval has the same start and end as the specified Interval.
  3881. * @param {Interval} other
  3882. * @return {boolean}
  3883. */
  3884. ;
  3885. _proto.equals = function equals(other) {
  3886. if (!this.isValid || !other.isValid) {
  3887. return false;
  3888. }
  3889. return this.s.equals(other.s) && this.e.equals(other.e);
  3890. }
  3891. /**
  3892. * Return an Interval representing the intersection of this Interval and the specified Interval.
  3893. * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals.
  3894. * Returns null if the intersection is empty, meaning, the intervals don't intersect.
  3895. * @param {Interval} other
  3896. * @return {Interval}
  3897. */
  3898. ;
  3899. _proto.intersection = function intersection(other) {
  3900. if (!this.isValid) return this;
  3901. var s = this.s > other.s ? this.s : other.s,
  3902. e = this.e < other.e ? this.e : other.e;
  3903. if (s >= e) {
  3904. return null;
  3905. } else {
  3906. return Interval.fromDateTimes(s, e);
  3907. }
  3908. }
  3909. /**
  3910. * Return an Interval representing the union of this Interval and the specified Interval.
  3911. * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals.
  3912. * @param {Interval} other
  3913. * @return {Interval}
  3914. */
  3915. ;
  3916. _proto.union = function union(other) {
  3917. if (!this.isValid) return this;
  3918. var s = this.s < other.s ? this.s : other.s,
  3919. e = this.e > other.e ? this.e : other.e;
  3920. return Interval.fromDateTimes(s, e);
  3921. }
  3922. /**
  3923. * Merge an array of Intervals into a equivalent minimal set of Intervals.
  3924. * Combines overlapping and adjacent Intervals.
  3925. * @param {[Interval]} intervals
  3926. * @return {[Interval]}
  3927. */
  3928. ;
  3929. Interval.merge = function merge(intervals) {
  3930. var _intervals$sort$reduc = intervals.sort(function (a, b) {
  3931. return a.s - b.s;
  3932. }).reduce(function (_ref2, item) {
  3933. var sofar = _ref2[0],
  3934. current = _ref2[1];
  3935. if (!current) {
  3936. return [sofar, item];
  3937. } else if (current.overlaps(item) || current.abutsStart(item)) {
  3938. return [sofar, current.union(item)];
  3939. } else {
  3940. return [sofar.concat([current]), item];
  3941. }
  3942. }, [[], null]),
  3943. found = _intervals$sort$reduc[0],
  3944. final = _intervals$sort$reduc[1];
  3945. if (final) {
  3946. found.push(final);
  3947. }
  3948. return found;
  3949. }
  3950. /**
  3951. * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.
  3952. * @param {[Interval]} intervals
  3953. * @return {[Interval]}
  3954. */
  3955. ;
  3956. Interval.xor = function xor(intervals) {
  3957. var _Array$prototype;
  3958. var start = null,
  3959. currentCount = 0;
  3960. var results = [],
  3961. ends = intervals.map(function (i) {
  3962. return [{
  3963. time: i.s,
  3964. type: "s"
  3965. }, {
  3966. time: i.e,
  3967. type: "e"
  3968. }];
  3969. }),
  3970. flattened = (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, ends),
  3971. arr = flattened.sort(function (a, b) {
  3972. return a.time - b.time;
  3973. });
  3974. for (var _iterator = _createForOfIteratorHelperLoose(arr), _step; !(_step = _iterator()).done;) {
  3975. var i = _step.value;
  3976. currentCount += i.type === "s" ? 1 : -1;
  3977. if (currentCount === 1) {
  3978. start = i.time;
  3979. } else {
  3980. if (start && +start !== +i.time) {
  3981. results.push(Interval.fromDateTimes(start, i.time));
  3982. }
  3983. start = null;
  3984. }
  3985. }
  3986. return Interval.merge(results);
  3987. }
  3988. /**
  3989. * Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.
  3990. * @param {...Interval} intervals
  3991. * @return {[Interval]}
  3992. */
  3993. ;
  3994. _proto.difference = function difference() {
  3995. var _this2 = this;
  3996. for (var _len2 = arguments.length, intervals = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3997. intervals[_key2] = arguments[_key2];
  3998. }
  3999. return Interval.xor([this].concat(intervals)).map(function (i) {
  4000. return _this2.intersection(i);
  4001. }).filter(function (i) {
  4002. return i && !i.isEmpty();
  4003. });
  4004. }
  4005. /**
  4006. * Returns a string representation of this Interval appropriate for debugging.
  4007. * @return {string}
  4008. */
  4009. ;
  4010. _proto.toString = function toString() {
  4011. if (!this.isValid) return INVALID$1;
  4012. return "[" + this.s.toISO() + " \u2013 " + this.e.toISO() + ")";
  4013. }
  4014. /**
  4015. * Returns an ISO 8601-compliant string representation of this Interval.
  4016. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  4017. * @param {Object} opts - The same options as {@link DateTime.toISO}
  4018. * @return {string}
  4019. */
  4020. ;
  4021. _proto.toISO = function toISO(opts) {
  4022. if (!this.isValid) return INVALID$1;
  4023. return this.s.toISO(opts) + "/" + this.e.toISO(opts);
  4024. }
  4025. /**
  4026. * Returns an ISO 8601-compliant string representation of date of this Interval.
  4027. * The time components are ignored.
  4028. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  4029. * @return {string}
  4030. */
  4031. ;
  4032. _proto.toISODate = function toISODate() {
  4033. if (!this.isValid) return INVALID$1;
  4034. return this.s.toISODate() + "/" + this.e.toISODate();
  4035. }
  4036. /**
  4037. * Returns an ISO 8601-compliant string representation of time of this Interval.
  4038. * The date components are ignored.
  4039. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  4040. * @param {Object} opts - The same options as {@link DateTime.toISO}
  4041. * @return {string}
  4042. */
  4043. ;
  4044. _proto.toISOTime = function toISOTime(opts) {
  4045. if (!this.isValid) return INVALID$1;
  4046. return this.s.toISOTime(opts) + "/" + this.e.toISOTime(opts);
  4047. }
  4048. /**
  4049. * Returns a string representation of this Interval formatted according to the specified format string.
  4050. * @param {string} dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details.
  4051. * @param {Object} opts - options
  4052. * @param {string} [opts.separator = ' – '] - a separator to place between the start and end representations
  4053. * @return {string}
  4054. */
  4055. ;
  4056. _proto.toFormat = function toFormat(dateFormat, _temp2) {
  4057. var _ref3 = _temp2 === void 0 ? {} : _temp2,
  4058. _ref3$separator = _ref3.separator,
  4059. separator = _ref3$separator === void 0 ? " – " : _ref3$separator;
  4060. if (!this.isValid) return INVALID$1;
  4061. return "" + this.s.toFormat(dateFormat) + separator + this.e.toFormat(dateFormat);
  4062. }
  4063. /**
  4064. * Return a Duration representing the time spanned by this interval.
  4065. * @param {string|string[]} [unit=['milliseconds']] - the unit or units (such as 'hours' or 'days') to include in the duration.
  4066. * @param {Object} opts - options that affect the creation of the Duration
  4067. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  4068. * @example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 }
  4069. * @example Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 }
  4070. * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 }
  4071. * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 }
  4072. * @example Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 }
  4073. * @return {Duration}
  4074. */
  4075. ;
  4076. _proto.toDuration = function toDuration(unit, opts) {
  4077. if (!this.isValid) {
  4078. return Duration.invalid(this.invalidReason);
  4079. }
  4080. return this.e.diff(this.s, unit, opts);
  4081. }
  4082. /**
  4083. * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes
  4084. * @param {function} mapFn
  4085. * @return {Interval}
  4086. * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC())
  4087. * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 }))
  4088. */
  4089. ;
  4090. _proto.mapEndpoints = function mapEndpoints(mapFn) {
  4091. return Interval.fromDateTimes(mapFn(this.s), mapFn(this.e));
  4092. };
  4093. _createClass(Interval, [{
  4094. key: "start",
  4095. get: function get() {
  4096. return this.isValid ? this.s : null;
  4097. }
  4098. /**
  4099. * Returns the end of the Interval
  4100. * @type {DateTime}
  4101. */
  4102. }, {
  4103. key: "end",
  4104. get: function get() {
  4105. return this.isValid ? this.e : null;
  4106. }
  4107. /**
  4108. * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
  4109. * @type {boolean}
  4110. */
  4111. }, {
  4112. key: "isValid",
  4113. get: function get() {
  4114. return this.invalidReason === null;
  4115. }
  4116. /**
  4117. * Returns an error code if this Interval is invalid, or null if the Interval is valid
  4118. * @type {string}
  4119. */
  4120. }, {
  4121. key: "invalidReason",
  4122. get: function get() {
  4123. return this.invalid ? this.invalid.reason : null;
  4124. }
  4125. /**
  4126. * Returns an explanation of why this Interval became invalid, or null if the Interval is valid
  4127. * @type {string}
  4128. */
  4129. }, {
  4130. key: "invalidExplanation",
  4131. get: function get() {
  4132. return this.invalid ? this.invalid.explanation : null;
  4133. }
  4134. }]);
  4135. return Interval;
  4136. }();
  4137. /**
  4138. * The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment.
  4139. */
  4140. var Info = /*#__PURE__*/function () {
  4141. function Info() {}
  4142. /**
  4143. * Return whether the specified zone contains a DST.
  4144. * @param {string|Zone} [zone='local'] - Zone to check. Defaults to the environment's local zone.
  4145. * @return {boolean}
  4146. */
  4147. Info.hasDST = function hasDST(zone) {
  4148. if (zone === void 0) {
  4149. zone = Settings.defaultZone;
  4150. }
  4151. var proto = DateTime.now().setZone(zone).set({
  4152. month: 12
  4153. });
  4154. return !zone.universal && proto.offset !== proto.set({
  4155. month: 6
  4156. }).offset;
  4157. }
  4158. /**
  4159. * Return whether the specified zone is a valid IANA specifier.
  4160. * @param {string} zone - Zone to check
  4161. * @return {boolean}
  4162. */
  4163. ;
  4164. Info.isValidIANAZone = function isValidIANAZone(zone) {
  4165. return IANAZone.isValidSpecifier(zone) && IANAZone.isValidZone(zone);
  4166. }
  4167. /**
  4168. * Converts the input into a {@link Zone} instance.
  4169. *
  4170. * * If `input` is already a Zone instance, it is returned unchanged.
  4171. * * If `input` is a string containing a valid time zone name, a Zone instance
  4172. * with that name is returned.
  4173. * * If `input` is a string that doesn't refer to a known time zone, a Zone
  4174. * instance with {@link Zone.isValid} == false is returned.
  4175. * * If `input is a number, a Zone instance with the specified fixed offset
  4176. * in minutes is returned.
  4177. * * If `input` is `null` or `undefined`, the default zone is returned.
  4178. * @param {string|Zone|number} [input] - the value to be converted
  4179. * @return {Zone}
  4180. */
  4181. ;
  4182. Info.normalizeZone = function normalizeZone$1(input) {
  4183. return normalizeZone(input, Settings.defaultZone);
  4184. }
  4185. /**
  4186. * Return an array of standalone month names.
  4187. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  4188. * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
  4189. * @param {Object} opts - options
  4190. * @param {string} [opts.locale] - the locale code
  4191. * @param {string} [opts.numberingSystem=null] - the numbering system
  4192. * @param {string} [opts.locObj=null] - an existing locale object to use
  4193. * @param {string} [opts.outputCalendar='gregory'] - the calendar
  4194. * @example Info.months()[0] //=> 'January'
  4195. * @example Info.months('short')[0] //=> 'Jan'
  4196. * @example Info.months('numeric')[0] //=> '1'
  4197. * @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
  4198. * @example Info.months('numeric', { locale: 'ar' })[0] //=> '١'
  4199. * @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'
  4200. * @return {[string]}
  4201. */
  4202. ;
  4203. Info.months = function months(length, _temp) {
  4204. if (length === void 0) {
  4205. length = "long";
  4206. }
  4207. var _ref = _temp === void 0 ? {} : _temp,
  4208. _ref$locale = _ref.locale,
  4209. locale = _ref$locale === void 0 ? null : _ref$locale,
  4210. _ref$numberingSystem = _ref.numberingSystem,
  4211. numberingSystem = _ref$numberingSystem === void 0 ? null : _ref$numberingSystem,
  4212. _ref$locObj = _ref.locObj,
  4213. locObj = _ref$locObj === void 0 ? null : _ref$locObj,
  4214. _ref$outputCalendar = _ref.outputCalendar,
  4215. outputCalendar = _ref$outputCalendar === void 0 ? "gregory" : _ref$outputCalendar;
  4216. return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
  4217. }
  4218. /**
  4219. * Return an array of format month names.
  4220. * Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that
  4221. * changes the string.
  4222. * See {@link months}
  4223. * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
  4224. * @param {Object} opts - options
  4225. * @param {string} [opts.locale] - the locale code
  4226. * @param {string} [opts.numberingSystem=null] - the numbering system
  4227. * @param {string} [opts.locObj=null] - an existing locale object to use
  4228. * @param {string} [opts.outputCalendar='gregory'] - the calendar
  4229. * @return {[string]}
  4230. */
  4231. ;
  4232. Info.monthsFormat = function monthsFormat(length, _temp2) {
  4233. if (length === void 0) {
  4234. length = "long";
  4235. }
  4236. var _ref2 = _temp2 === void 0 ? {} : _temp2,
  4237. _ref2$locale = _ref2.locale,
  4238. locale = _ref2$locale === void 0 ? null : _ref2$locale,
  4239. _ref2$numberingSystem = _ref2.numberingSystem,
  4240. numberingSystem = _ref2$numberingSystem === void 0 ? null : _ref2$numberingSystem,
  4241. _ref2$locObj = _ref2.locObj,
  4242. locObj = _ref2$locObj === void 0 ? null : _ref2$locObj,
  4243. _ref2$outputCalendar = _ref2.outputCalendar,
  4244. outputCalendar = _ref2$outputCalendar === void 0 ? "gregory" : _ref2$outputCalendar;
  4245. return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
  4246. }
  4247. /**
  4248. * Return an array of standalone week names.
  4249. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  4250. * @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
  4251. * @param {Object} opts - options
  4252. * @param {string} [opts.locale] - the locale code
  4253. * @param {string} [opts.numberingSystem=null] - the numbering system
  4254. * @param {string} [opts.locObj=null] - an existing locale object to use
  4255. * @example Info.weekdays()[0] //=> 'Monday'
  4256. * @example Info.weekdays('short')[0] //=> 'Mon'
  4257. * @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'
  4258. * @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'
  4259. * @return {[string]}
  4260. */
  4261. ;
  4262. Info.weekdays = function weekdays(length, _temp3) {
  4263. if (length === void 0) {
  4264. length = "long";
  4265. }
  4266. var _ref3 = _temp3 === void 0 ? {} : _temp3,
  4267. _ref3$locale = _ref3.locale,
  4268. locale = _ref3$locale === void 0 ? null : _ref3$locale,
  4269. _ref3$numberingSystem = _ref3.numberingSystem,
  4270. numberingSystem = _ref3$numberingSystem === void 0 ? null : _ref3$numberingSystem,
  4271. _ref3$locObj = _ref3.locObj,
  4272. locObj = _ref3$locObj === void 0 ? null : _ref3$locObj;
  4273. return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
  4274. }
  4275. /**
  4276. * Return an array of format week names.
  4277. * Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that
  4278. * changes the string.
  4279. * See {@link weekdays}
  4280. * @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
  4281. * @param {Object} opts - options
  4282. * @param {string} [opts.locale=null] - the locale code
  4283. * @param {string} [opts.numberingSystem=null] - the numbering system
  4284. * @param {string} [opts.locObj=null] - an existing locale object to use
  4285. * @return {[string]}
  4286. */
  4287. ;
  4288. Info.weekdaysFormat = function weekdaysFormat(length, _temp4) {
  4289. if (length === void 0) {
  4290. length = "long";
  4291. }
  4292. var _ref4 = _temp4 === void 0 ? {} : _temp4,
  4293. _ref4$locale = _ref4.locale,
  4294. locale = _ref4$locale === void 0 ? null : _ref4$locale,
  4295. _ref4$numberingSystem = _ref4.numberingSystem,
  4296. numberingSystem = _ref4$numberingSystem === void 0 ? null : _ref4$numberingSystem,
  4297. _ref4$locObj = _ref4.locObj,
  4298. locObj = _ref4$locObj === void 0 ? null : _ref4$locObj;
  4299. return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
  4300. }
  4301. /**
  4302. * Return an array of meridiems.
  4303. * @param {Object} opts - options
  4304. * @param {string} [opts.locale] - the locale code
  4305. * @example Info.meridiems() //=> [ 'AM', 'PM' ]
  4306. * @example Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]
  4307. * @return {[string]}
  4308. */
  4309. ;
  4310. Info.meridiems = function meridiems(_temp5) {
  4311. var _ref5 = _temp5 === void 0 ? {} : _temp5,
  4312. _ref5$locale = _ref5.locale,
  4313. locale = _ref5$locale === void 0 ? null : _ref5$locale;
  4314. return Locale.create(locale).meridiems();
  4315. }
  4316. /**
  4317. * Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.
  4318. * @param {string} [length='short'] - the length of the era representation, such as "short" or "long".
  4319. * @param {Object} opts - options
  4320. * @param {string} [opts.locale] - the locale code
  4321. * @example Info.eras() //=> [ 'BC', 'AD' ]
  4322. * @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]
  4323. * @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]
  4324. * @return {[string]}
  4325. */
  4326. ;
  4327. Info.eras = function eras(length, _temp6) {
  4328. if (length === void 0) {
  4329. length = "short";
  4330. }
  4331. var _ref6 = _temp6 === void 0 ? {} : _temp6,
  4332. _ref6$locale = _ref6.locale,
  4333. locale = _ref6$locale === void 0 ? null : _ref6$locale;
  4334. return Locale.create(locale, null, "gregory").eras(length);
  4335. }
  4336. /**
  4337. * Return the set of available features in this environment.
  4338. * Some features of Luxon are not available in all environments. For example, on older browsers, timezone support is not available. Use this function to figure out if that's the case.
  4339. * Keys:
  4340. * * `zones`: whether this environment supports IANA timezones
  4341. * * `intlTokens`: whether this environment supports internationalized token-based formatting/parsing
  4342. * * `intl`: whether this environment supports general internationalization
  4343. * * `relative`: whether this environment supports relative time formatting
  4344. * @example Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false }
  4345. * @return {Object}
  4346. */
  4347. ;
  4348. Info.features = function features() {
  4349. var intl = false,
  4350. intlTokens = false,
  4351. zones = false,
  4352. relative = false;
  4353. if (hasIntl()) {
  4354. intl = true;
  4355. intlTokens = hasFormatToParts();
  4356. relative = hasRelative();
  4357. try {
  4358. zones = new Intl.DateTimeFormat("en", {
  4359. timeZone: "America/New_York"
  4360. }).resolvedOptions().timeZone === "America/New_York";
  4361. } catch (e) {
  4362. zones = false;
  4363. }
  4364. }
  4365. return {
  4366. intl: intl,
  4367. intlTokens: intlTokens,
  4368. zones: zones,
  4369. relative: relative
  4370. };
  4371. };
  4372. return Info;
  4373. }();
  4374. function dayDiff(earlier, later) {
  4375. var utcDayStart = function utcDayStart(dt) {
  4376. return dt.toUTC(0, {
  4377. keepLocalTime: true
  4378. }).startOf("day").valueOf();
  4379. },
  4380. ms = utcDayStart(later) - utcDayStart(earlier);
  4381. return Math.floor(Duration.fromMillis(ms).as("days"));
  4382. }
  4383. function highOrderDiffs(cursor, later, units) {
  4384. var differs = [["years", function (a, b) {
  4385. return b.year - a.year;
  4386. }], ["quarters", function (a, b) {
  4387. return b.quarter - a.quarter;
  4388. }], ["months", function (a, b) {
  4389. return b.month - a.month + (b.year - a.year) * 12;
  4390. }], ["weeks", function (a, b) {
  4391. var days = dayDiff(a, b);
  4392. return (days - days % 7) / 7;
  4393. }], ["days", dayDiff]];
  4394. var results = {};
  4395. var lowestOrder, highWater;
  4396. for (var _i = 0, _differs = differs; _i < _differs.length; _i++) {
  4397. var _differs$_i = _differs[_i],
  4398. unit = _differs$_i[0],
  4399. differ = _differs$_i[1];
  4400. if (units.indexOf(unit) >= 0) {
  4401. var _cursor$plus;
  4402. lowestOrder = unit;
  4403. var delta = differ(cursor, later);
  4404. highWater = cursor.plus((_cursor$plus = {}, _cursor$plus[unit] = delta, _cursor$plus));
  4405. if (highWater > later) {
  4406. var _cursor$plus2;
  4407. cursor = cursor.plus((_cursor$plus2 = {}, _cursor$plus2[unit] = delta - 1, _cursor$plus2));
  4408. delta -= 1;
  4409. } else {
  4410. cursor = highWater;
  4411. }
  4412. results[unit] = delta;
  4413. }
  4414. }
  4415. return [cursor, results, highWater, lowestOrder];
  4416. }
  4417. function _diff (earlier, later, units, opts) {
  4418. var _highOrderDiffs = highOrderDiffs(earlier, later, units),
  4419. cursor = _highOrderDiffs[0],
  4420. results = _highOrderDiffs[1],
  4421. highWater = _highOrderDiffs[2],
  4422. lowestOrder = _highOrderDiffs[3];
  4423. var remainingMillis = later - cursor;
  4424. var lowerOrderUnits = units.filter(function (u) {
  4425. return ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0;
  4426. });
  4427. if (lowerOrderUnits.length === 0) {
  4428. if (highWater < later) {
  4429. var _cursor$plus3;
  4430. highWater = cursor.plus((_cursor$plus3 = {}, _cursor$plus3[lowestOrder] = 1, _cursor$plus3));
  4431. }
  4432. if (highWater !== cursor) {
  4433. results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor);
  4434. }
  4435. }
  4436. var duration = Duration.fromObject(Object.assign(results, opts));
  4437. if (lowerOrderUnits.length > 0) {
  4438. var _Duration$fromMillis;
  4439. return (_Duration$fromMillis = Duration.fromMillis(remainingMillis, opts)).shiftTo.apply(_Duration$fromMillis, lowerOrderUnits).plus(duration);
  4440. } else {
  4441. return duration;
  4442. }
  4443. }
  4444. var numberingSystems = {
  4445. arab: "[\u0660-\u0669]",
  4446. arabext: "[\u06F0-\u06F9]",
  4447. bali: "[\u1B50-\u1B59]",
  4448. beng: "[\u09E6-\u09EF]",
  4449. deva: "[\u0966-\u096F]",
  4450. fullwide: "[\uFF10-\uFF19]",
  4451. gujr: "[\u0AE6-\u0AEF]",
  4452. hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
  4453. khmr: "[\u17E0-\u17E9]",
  4454. knda: "[\u0CE6-\u0CEF]",
  4455. laoo: "[\u0ED0-\u0ED9]",
  4456. limb: "[\u1946-\u194F]",
  4457. mlym: "[\u0D66-\u0D6F]",
  4458. mong: "[\u1810-\u1819]",
  4459. mymr: "[\u1040-\u1049]",
  4460. orya: "[\u0B66-\u0B6F]",
  4461. tamldec: "[\u0BE6-\u0BEF]",
  4462. telu: "[\u0C66-\u0C6F]",
  4463. thai: "[\u0E50-\u0E59]",
  4464. tibt: "[\u0F20-\u0F29]",
  4465. latn: "\\d"
  4466. };
  4467. var numberingSystemsUTF16 = {
  4468. arab: [1632, 1641],
  4469. arabext: [1776, 1785],
  4470. bali: [6992, 7001],
  4471. beng: [2534, 2543],
  4472. deva: [2406, 2415],
  4473. fullwide: [65296, 65303],
  4474. gujr: [2790, 2799],
  4475. khmr: [6112, 6121],
  4476. knda: [3302, 3311],
  4477. laoo: [3792, 3801],
  4478. limb: [6470, 6479],
  4479. mlym: [3430, 3439],
  4480. mong: [6160, 6169],
  4481. mymr: [4160, 4169],
  4482. orya: [2918, 2927],
  4483. tamldec: [3046, 3055],
  4484. telu: [3174, 3183],
  4485. thai: [3664, 3673],
  4486. tibt: [3872, 3881]
  4487. }; // eslint-disable-next-line
  4488. var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
  4489. function parseDigits(str) {
  4490. var value = parseInt(str, 10);
  4491. if (isNaN(value)) {
  4492. value = "";
  4493. for (var i = 0; i < str.length; i++) {
  4494. var code = str.charCodeAt(i);
  4495. if (str[i].search(numberingSystems.hanidec) !== -1) {
  4496. value += hanidecChars.indexOf(str[i]);
  4497. } else {
  4498. for (var key in numberingSystemsUTF16) {
  4499. var _numberingSystemsUTF = numberingSystemsUTF16[key],
  4500. min = _numberingSystemsUTF[0],
  4501. max = _numberingSystemsUTF[1];
  4502. if (code >= min && code <= max) {
  4503. value += code - min;
  4504. }
  4505. }
  4506. }
  4507. }
  4508. return parseInt(value, 10);
  4509. } else {
  4510. return value;
  4511. }
  4512. }
  4513. function digitRegex(_ref, append) {
  4514. var numberingSystem = _ref.numberingSystem;
  4515. if (append === void 0) {
  4516. append = "";
  4517. }
  4518. return new RegExp("" + numberingSystems[numberingSystem || "latn"] + append);
  4519. }
  4520. var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
  4521. function intUnit(regex, post) {
  4522. if (post === void 0) {
  4523. post = function post(i) {
  4524. return i;
  4525. };
  4526. }
  4527. return {
  4528. regex: regex,
  4529. deser: function deser(_ref) {
  4530. var s = _ref[0];
  4531. return post(parseDigits(s));
  4532. }
  4533. };
  4534. }
  4535. var NBSP = String.fromCharCode(160);
  4536. var spaceOrNBSP = "( |" + NBSP + ")";
  4537. var spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
  4538. function fixListRegex(s) {
  4539. // make dots optional and also make them literal
  4540. // make space and non breakable space characters interchangeable
  4541. return s.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
  4542. }
  4543. function stripInsensitivities(s) {
  4544. return s.replace(/\./g, "") // ignore dots that were made optional
  4545. .replace(spaceOrNBSPRegExp, " ") // interchange space and nbsp
  4546. .toLowerCase();
  4547. }
  4548. function oneOf(strings, startIndex) {
  4549. if (strings === null) {
  4550. return null;
  4551. } else {
  4552. return {
  4553. regex: RegExp(strings.map(fixListRegex).join("|")),
  4554. deser: function deser(_ref2) {
  4555. var s = _ref2[0];
  4556. return strings.findIndex(function (i) {
  4557. return stripInsensitivities(s) === stripInsensitivities(i);
  4558. }) + startIndex;
  4559. }
  4560. };
  4561. }
  4562. }
  4563. function offset(regex, groups) {
  4564. return {
  4565. regex: regex,
  4566. deser: function deser(_ref3) {
  4567. var h = _ref3[1],
  4568. m = _ref3[2];
  4569. return signedOffset(h, m);
  4570. },
  4571. groups: groups
  4572. };
  4573. }
  4574. function simple(regex) {
  4575. return {
  4576. regex: regex,
  4577. deser: function deser(_ref4) {
  4578. var s = _ref4[0];
  4579. return s;
  4580. }
  4581. };
  4582. }
  4583. function escapeToken(value) {
  4584. // eslint-disable-next-line no-useless-escape
  4585. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  4586. }
  4587. function unitForToken(token, loc) {
  4588. var one = digitRegex(loc),
  4589. two = digitRegex(loc, "{2}"),
  4590. three = digitRegex(loc, "{3}"),
  4591. four = digitRegex(loc, "{4}"),
  4592. six = digitRegex(loc, "{6}"),
  4593. oneOrTwo = digitRegex(loc, "{1,2}"),
  4594. oneToThree = digitRegex(loc, "{1,3}"),
  4595. oneToSix = digitRegex(loc, "{1,6}"),
  4596. oneToNine = digitRegex(loc, "{1,9}"),
  4597. twoToFour = digitRegex(loc, "{2,4}"),
  4598. fourToSix = digitRegex(loc, "{4,6}"),
  4599. literal = function literal(t) {
  4600. return {
  4601. regex: RegExp(escapeToken(t.val)),
  4602. deser: function deser(_ref5) {
  4603. var s = _ref5[0];
  4604. return s;
  4605. },
  4606. literal: true
  4607. };
  4608. },
  4609. unitate = function unitate(t) {
  4610. if (token.literal) {
  4611. return literal(t);
  4612. }
  4613. switch (t.val) {
  4614. // era
  4615. case "G":
  4616. return oneOf(loc.eras("short", false), 0);
  4617. case "GG":
  4618. return oneOf(loc.eras("long", false), 0);
  4619. // years
  4620. case "y":
  4621. return intUnit(oneToSix);
  4622. case "yy":
  4623. return intUnit(twoToFour, untruncateYear);
  4624. case "yyyy":
  4625. return intUnit(four);
  4626. case "yyyyy":
  4627. return intUnit(fourToSix);
  4628. case "yyyyyy":
  4629. return intUnit(six);
  4630. // months
  4631. case "M":
  4632. return intUnit(oneOrTwo);
  4633. case "MM":
  4634. return intUnit(two);
  4635. case "MMM":
  4636. return oneOf(loc.months("short", true, false), 1);
  4637. case "MMMM":
  4638. return oneOf(loc.months("long", true, false), 1);
  4639. case "L":
  4640. return intUnit(oneOrTwo);
  4641. case "LL":
  4642. return intUnit(two);
  4643. case "LLL":
  4644. return oneOf(loc.months("short", false, false), 1);
  4645. case "LLLL":
  4646. return oneOf(loc.months("long", false, false), 1);
  4647. // dates
  4648. case "d":
  4649. return intUnit(oneOrTwo);
  4650. case "dd":
  4651. return intUnit(two);
  4652. // ordinals
  4653. case "o":
  4654. return intUnit(oneToThree);
  4655. case "ooo":
  4656. return intUnit(three);
  4657. // time
  4658. case "HH":
  4659. return intUnit(two);
  4660. case "H":
  4661. return intUnit(oneOrTwo);
  4662. case "hh":
  4663. return intUnit(two);
  4664. case "h":
  4665. return intUnit(oneOrTwo);
  4666. case "mm":
  4667. return intUnit(two);
  4668. case "m":
  4669. return intUnit(oneOrTwo);
  4670. case "q":
  4671. return intUnit(oneOrTwo);
  4672. case "qq":
  4673. return intUnit(two);
  4674. case "s":
  4675. return intUnit(oneOrTwo);
  4676. case "ss":
  4677. return intUnit(two);
  4678. case "S":
  4679. return intUnit(oneToThree);
  4680. case "SSS":
  4681. return intUnit(three);
  4682. case "u":
  4683. return simple(oneToNine);
  4684. // meridiem
  4685. case "a":
  4686. return oneOf(loc.meridiems(), 0);
  4687. // weekYear (k)
  4688. case "kkkk":
  4689. return intUnit(four);
  4690. case "kk":
  4691. return intUnit(twoToFour, untruncateYear);
  4692. // weekNumber (W)
  4693. case "W":
  4694. return intUnit(oneOrTwo);
  4695. case "WW":
  4696. return intUnit(two);
  4697. // weekdays
  4698. case "E":
  4699. case "c":
  4700. return intUnit(one);
  4701. case "EEE":
  4702. return oneOf(loc.weekdays("short", false, false), 1);
  4703. case "EEEE":
  4704. return oneOf(loc.weekdays("long", false, false), 1);
  4705. case "ccc":
  4706. return oneOf(loc.weekdays("short", true, false), 1);
  4707. case "cccc":
  4708. return oneOf(loc.weekdays("long", true, false), 1);
  4709. // offset/zone
  4710. case "Z":
  4711. case "ZZ":
  4712. return offset(new RegExp("([+-]" + oneOrTwo.source + ")(?::(" + two.source + "))?"), 2);
  4713. case "ZZZ":
  4714. return offset(new RegExp("([+-]" + oneOrTwo.source + ")(" + two.source + ")?"), 2);
  4715. // we don't support ZZZZ (PST) or ZZZZZ (Pacific Standard Time) in parsing
  4716. // because we don't have any way to figure out what they are
  4717. case "z":
  4718. return simple(/[a-z_+-/]{1,256}?/i);
  4719. default:
  4720. return literal(t);
  4721. }
  4722. };
  4723. var unit = unitate(token) || {
  4724. invalidReason: MISSING_FTP
  4725. };
  4726. unit.token = token;
  4727. return unit;
  4728. }
  4729. var partTypeStyleToTokenVal = {
  4730. year: {
  4731. "2-digit": "yy",
  4732. numeric: "yyyyy"
  4733. },
  4734. month: {
  4735. numeric: "M",
  4736. "2-digit": "MM",
  4737. short: "MMM",
  4738. long: "MMMM"
  4739. },
  4740. day: {
  4741. numeric: "d",
  4742. "2-digit": "dd"
  4743. },
  4744. weekday: {
  4745. short: "EEE",
  4746. long: "EEEE"
  4747. },
  4748. dayperiod: "a",
  4749. dayPeriod: "a",
  4750. hour: {
  4751. numeric: "h",
  4752. "2-digit": "hh"
  4753. },
  4754. minute: {
  4755. numeric: "m",
  4756. "2-digit": "mm"
  4757. },
  4758. second: {
  4759. numeric: "s",
  4760. "2-digit": "ss"
  4761. }
  4762. };
  4763. function tokenForPart(part, locale, formatOpts) {
  4764. var type = part.type,
  4765. value = part.value;
  4766. if (type === "literal") {
  4767. return {
  4768. literal: true,
  4769. val: value
  4770. };
  4771. }
  4772. var style = formatOpts[type];
  4773. var val = partTypeStyleToTokenVal[type];
  4774. if (typeof val === "object") {
  4775. val = val[style];
  4776. }
  4777. if (val) {
  4778. return {
  4779. literal: false,
  4780. val: val
  4781. };
  4782. }
  4783. return undefined;
  4784. }
  4785. function buildRegex(units) {
  4786. var re = units.map(function (u) {
  4787. return u.regex;
  4788. }).reduce(function (f, r) {
  4789. return f + "(" + r.source + ")";
  4790. }, "");
  4791. return ["^" + re + "$", units];
  4792. }
  4793. function match(input, regex, handlers) {
  4794. var matches = input.match(regex);
  4795. if (matches) {
  4796. var all = {};
  4797. var matchIndex = 1;
  4798. for (var i in handlers) {
  4799. if (hasOwnProperty(handlers, i)) {
  4800. var h = handlers[i],
  4801. groups = h.groups ? h.groups + 1 : 1;
  4802. if (!h.literal && h.token) {
  4803. all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
  4804. }
  4805. matchIndex += groups;
  4806. }
  4807. }
  4808. return [matches, all];
  4809. } else {
  4810. return [matches, {}];
  4811. }
  4812. }
  4813. function dateTimeFromMatches(matches) {
  4814. var toField = function toField(token) {
  4815. switch (token) {
  4816. case "S":
  4817. return "millisecond";
  4818. case "s":
  4819. return "second";
  4820. case "m":
  4821. return "minute";
  4822. case "h":
  4823. case "H":
  4824. return "hour";
  4825. case "d":
  4826. return "day";
  4827. case "o":
  4828. return "ordinal";
  4829. case "L":
  4830. case "M":
  4831. return "month";
  4832. case "y":
  4833. return "year";
  4834. case "E":
  4835. case "c":
  4836. return "weekday";
  4837. case "W":
  4838. return "weekNumber";
  4839. case "k":
  4840. return "weekYear";
  4841. case "q":
  4842. return "quarter";
  4843. default:
  4844. return null;
  4845. }
  4846. };
  4847. var zone;
  4848. if (!isUndefined(matches.Z)) {
  4849. zone = new FixedOffsetZone(matches.Z);
  4850. } else if (!isUndefined(matches.z)) {
  4851. zone = IANAZone.create(matches.z);
  4852. } else {
  4853. zone = null;
  4854. }
  4855. if (!isUndefined(matches.q)) {
  4856. matches.M = (matches.q - 1) * 3 + 1;
  4857. }
  4858. if (!isUndefined(matches.h)) {
  4859. if (matches.h < 12 && matches.a === 1) {
  4860. matches.h += 12;
  4861. } else if (matches.h === 12 && matches.a === 0) {
  4862. matches.h = 0;
  4863. }
  4864. }
  4865. if (matches.G === 0 && matches.y) {
  4866. matches.y = -matches.y;
  4867. }
  4868. if (!isUndefined(matches.u)) {
  4869. matches.S = parseMillis(matches.u);
  4870. }
  4871. var vals = Object.keys(matches).reduce(function (r, k) {
  4872. var f = toField(k);
  4873. if (f) {
  4874. r[f] = matches[k];
  4875. }
  4876. return r;
  4877. }, {});
  4878. return [vals, zone];
  4879. }
  4880. var dummyDateTimeCache = null;
  4881. function getDummyDateTime() {
  4882. if (!dummyDateTimeCache) {
  4883. dummyDateTimeCache = DateTime.fromMillis(1555555555555);
  4884. }
  4885. return dummyDateTimeCache;
  4886. }
  4887. function maybeExpandMacroToken(token, locale) {
  4888. if (token.literal) {
  4889. return token;
  4890. }
  4891. var formatOpts = Formatter.macroTokenToFormatOpts(token.val);
  4892. if (!formatOpts) {
  4893. return token;
  4894. }
  4895. var formatter = Formatter.create(locale, formatOpts);
  4896. var parts = formatter.formatDateTimeParts(getDummyDateTime());
  4897. var tokens = parts.map(function (p) {
  4898. return tokenForPart(p, locale, formatOpts);
  4899. });
  4900. if (tokens.includes(undefined)) {
  4901. return token;
  4902. }
  4903. return tokens;
  4904. }
  4905. function expandMacroTokens(tokens, locale) {
  4906. var _Array$prototype;
  4907. return (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, tokens.map(function (t) {
  4908. return maybeExpandMacroToken(t, locale);
  4909. }));
  4910. }
  4911. /**
  4912. * @private
  4913. */
  4914. function explainFromTokens(locale, input, format) {
  4915. var tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
  4916. units = tokens.map(function (t) {
  4917. return unitForToken(t, locale);
  4918. }),
  4919. disqualifyingUnit = units.find(function (t) {
  4920. return t.invalidReason;
  4921. });
  4922. if (disqualifyingUnit) {
  4923. return {
  4924. input: input,
  4925. tokens: tokens,
  4926. invalidReason: disqualifyingUnit.invalidReason
  4927. };
  4928. } else {
  4929. var _buildRegex = buildRegex(units),
  4930. regexString = _buildRegex[0],
  4931. handlers = _buildRegex[1],
  4932. regex = RegExp(regexString, "i"),
  4933. _match = match(input, regex, handlers),
  4934. rawMatches = _match[0],
  4935. matches = _match[1],
  4936. _ref6 = matches ? dateTimeFromMatches(matches) : [null, null],
  4937. result = _ref6[0],
  4938. zone = _ref6[1];
  4939. if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
  4940. throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
  4941. }
  4942. return {
  4943. input: input,
  4944. tokens: tokens,
  4945. regex: regex,
  4946. rawMatches: rawMatches,
  4947. matches: matches,
  4948. result: result,
  4949. zone: zone
  4950. };
  4951. }
  4952. }
  4953. function parseFromTokens(locale, input, format) {
  4954. var _explainFromTokens = explainFromTokens(locale, input, format),
  4955. result = _explainFromTokens.result,
  4956. zone = _explainFromTokens.zone,
  4957. invalidReason = _explainFromTokens.invalidReason;
  4958. return [result, zone, invalidReason];
  4959. }
  4960. var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
  4961. leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
  4962. function unitOutOfRange(unit, value) {
  4963. return new Invalid("unit out of range", "you specified " + value + " (of type " + typeof value + ") as a " + unit + ", which is invalid");
  4964. }
  4965. function dayOfWeek(year, month, day) {
  4966. var js = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
  4967. return js === 0 ? 7 : js;
  4968. }
  4969. function computeOrdinal(year, month, day) {
  4970. return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1];
  4971. }
  4972. function uncomputeOrdinal(year, ordinal) {
  4973. var table = isLeapYear(year) ? leapLadder : nonLeapLadder,
  4974. month0 = table.findIndex(function (i) {
  4975. return i < ordinal;
  4976. }),
  4977. day = ordinal - table[month0];
  4978. return {
  4979. month: month0 + 1,
  4980. day: day
  4981. };
  4982. }
  4983. /**
  4984. * @private
  4985. */
  4986. function gregorianToWeek(gregObj) {
  4987. var year = gregObj.year,
  4988. month = gregObj.month,
  4989. day = gregObj.day,
  4990. ordinal = computeOrdinal(year, month, day),
  4991. weekday = dayOfWeek(year, month, day);
  4992. var weekNumber = Math.floor((ordinal - weekday + 10) / 7),
  4993. weekYear;
  4994. if (weekNumber < 1) {
  4995. weekYear = year - 1;
  4996. weekNumber = weeksInWeekYear(weekYear);
  4997. } else if (weekNumber > weeksInWeekYear(year)) {
  4998. weekYear = year + 1;
  4999. weekNumber = 1;
  5000. } else {
  5001. weekYear = year;
  5002. }
  5003. return Object.assign({
  5004. weekYear: weekYear,
  5005. weekNumber: weekNumber,
  5006. weekday: weekday
  5007. }, timeObject(gregObj));
  5008. }
  5009. function weekToGregorian(weekData) {
  5010. var weekYear = weekData.weekYear,
  5011. weekNumber = weekData.weekNumber,
  5012. weekday = weekData.weekday,
  5013. weekdayOfJan4 = dayOfWeek(weekYear, 1, 4),
  5014. yearInDays = daysInYear(weekYear);
  5015. var ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3,
  5016. year;
  5017. if (ordinal < 1) {
  5018. year = weekYear - 1;
  5019. ordinal += daysInYear(year);
  5020. } else if (ordinal > yearInDays) {
  5021. year = weekYear + 1;
  5022. ordinal -= daysInYear(weekYear);
  5023. } else {
  5024. year = weekYear;
  5025. }
  5026. var _uncomputeOrdinal = uncomputeOrdinal(year, ordinal),
  5027. month = _uncomputeOrdinal.month,
  5028. day = _uncomputeOrdinal.day;
  5029. return Object.assign({
  5030. year: year,
  5031. month: month,
  5032. day: day
  5033. }, timeObject(weekData));
  5034. }
  5035. function gregorianToOrdinal(gregData) {
  5036. var year = gregData.year,
  5037. month = gregData.month,
  5038. day = gregData.day,
  5039. ordinal = computeOrdinal(year, month, day);
  5040. return Object.assign({
  5041. year: year,
  5042. ordinal: ordinal
  5043. }, timeObject(gregData));
  5044. }
  5045. function ordinalToGregorian(ordinalData) {
  5046. var year = ordinalData.year,
  5047. ordinal = ordinalData.ordinal,
  5048. _uncomputeOrdinal2 = uncomputeOrdinal(year, ordinal),
  5049. month = _uncomputeOrdinal2.month,
  5050. day = _uncomputeOrdinal2.day;
  5051. return Object.assign({
  5052. year: year,
  5053. month: month,
  5054. day: day
  5055. }, timeObject(ordinalData));
  5056. }
  5057. function hasInvalidWeekData(obj) {
  5058. var validYear = isInteger(obj.weekYear),
  5059. validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)),
  5060. validWeekday = integerBetween(obj.weekday, 1, 7);
  5061. if (!validYear) {
  5062. return unitOutOfRange("weekYear", obj.weekYear);
  5063. } else if (!validWeek) {
  5064. return unitOutOfRange("week", obj.week);
  5065. } else if (!validWeekday) {
  5066. return unitOutOfRange("weekday", obj.weekday);
  5067. } else return false;
  5068. }
  5069. function hasInvalidOrdinalData(obj) {
  5070. var validYear = isInteger(obj.year),
  5071. validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year));
  5072. if (!validYear) {
  5073. return unitOutOfRange("year", obj.year);
  5074. } else if (!validOrdinal) {
  5075. return unitOutOfRange("ordinal", obj.ordinal);
  5076. } else return false;
  5077. }
  5078. function hasInvalidGregorianData(obj) {
  5079. var validYear = isInteger(obj.year),
  5080. validMonth = integerBetween(obj.month, 1, 12),
  5081. validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month));
  5082. if (!validYear) {
  5083. return unitOutOfRange("year", obj.year);
  5084. } else if (!validMonth) {
  5085. return unitOutOfRange("month", obj.month);
  5086. } else if (!validDay) {
  5087. return unitOutOfRange("day", obj.day);
  5088. } else return false;
  5089. }
  5090. function hasInvalidTimeData(obj) {
  5091. var hour = obj.hour,
  5092. minute = obj.minute,
  5093. second = obj.second,
  5094. millisecond = obj.millisecond;
  5095. var validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0,
  5096. validMinute = integerBetween(minute, 0, 59),
  5097. validSecond = integerBetween(second, 0, 59),
  5098. validMillisecond = integerBetween(millisecond, 0, 999);
  5099. if (!validHour) {
  5100. return unitOutOfRange("hour", hour);
  5101. } else if (!validMinute) {
  5102. return unitOutOfRange("minute", minute);
  5103. } else if (!validSecond) {
  5104. return unitOutOfRange("second", second);
  5105. } else if (!validMillisecond) {
  5106. return unitOutOfRange("millisecond", millisecond);
  5107. } else return false;
  5108. }
  5109. var INVALID$2 = "Invalid DateTime";
  5110. var MAX_DATE = 8.64e15;
  5111. function unsupportedZone(zone) {
  5112. return new Invalid("unsupported zone", "the zone \"" + zone.name + "\" is not supported");
  5113. } // we cache week data on the DT object and this intermediates the cache
  5114. function possiblyCachedWeekData(dt) {
  5115. if (dt.weekData === null) {
  5116. dt.weekData = gregorianToWeek(dt.c);
  5117. }
  5118. return dt.weekData;
  5119. } // clone really means, "make a new object with these modifications". all "setters" really use this
  5120. // to create a new object while only changing some of the properties
  5121. function clone$1(inst, alts) {
  5122. var current = {
  5123. ts: inst.ts,
  5124. zone: inst.zone,
  5125. c: inst.c,
  5126. o: inst.o,
  5127. loc: inst.loc,
  5128. invalid: inst.invalid
  5129. };
  5130. return new DateTime(Object.assign({}, current, alts, {
  5131. old: current
  5132. }));
  5133. } // find the right offset a given local time. The o input is our guess, which determines which
  5134. // offset we'll pick in ambiguous cases (e.g. there are two 3 AMs b/c Fallback DST)
  5135. function fixOffset(localTS, o, tz) {
  5136. // Our UTC time is just a guess because our offset is just a guess
  5137. var utcGuess = localTS - o * 60 * 1000; // Test whether the zone matches the offset for this ts
  5138. var o2 = tz.offset(utcGuess); // If so, offset didn't change and we're done
  5139. if (o === o2) {
  5140. return [utcGuess, o];
  5141. } // If not, change the ts by the difference in the offset
  5142. utcGuess -= (o2 - o) * 60 * 1000; // If that gives us the local time we want, we're done
  5143. var o3 = tz.offset(utcGuess);
  5144. if (o2 === o3) {
  5145. return [utcGuess, o2];
  5146. } // If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time
  5147. return [localTS - Math.min(o2, o3) * 60 * 1000, Math.max(o2, o3)];
  5148. } // convert an epoch timestamp into a calendar object with the given offset
  5149. function tsToObj(ts, offset) {
  5150. ts += offset * 60 * 1000;
  5151. var d = new Date(ts);
  5152. return {
  5153. year: d.getUTCFullYear(),
  5154. month: d.getUTCMonth() + 1,
  5155. day: d.getUTCDate(),
  5156. hour: d.getUTCHours(),
  5157. minute: d.getUTCMinutes(),
  5158. second: d.getUTCSeconds(),
  5159. millisecond: d.getUTCMilliseconds()
  5160. };
  5161. } // convert a calendar object to a epoch timestamp
  5162. function objToTS(obj, offset, zone) {
  5163. return fixOffset(objToLocalTS(obj), offset, zone);
  5164. } // create a new DT instance by adding a duration, adjusting for DSTs
  5165. function adjustTime(inst, dur) {
  5166. var oPre = inst.o,
  5167. year = inst.c.year + Math.trunc(dur.years),
  5168. month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3,
  5169. c = Object.assign({}, inst.c, {
  5170. year: year,
  5171. month: month,
  5172. day: Math.min(inst.c.day, daysInMonth(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7
  5173. }),
  5174. millisToAdd = Duration.fromObject({
  5175. years: dur.years - Math.trunc(dur.years),
  5176. quarters: dur.quarters - Math.trunc(dur.quarters),
  5177. months: dur.months - Math.trunc(dur.months),
  5178. weeks: dur.weeks - Math.trunc(dur.weeks),
  5179. days: dur.days - Math.trunc(dur.days),
  5180. hours: dur.hours,
  5181. minutes: dur.minutes,
  5182. seconds: dur.seconds,
  5183. milliseconds: dur.milliseconds
  5184. }).as("milliseconds"),
  5185. localTS = objToLocalTS(c);
  5186. var _fixOffset = fixOffset(localTS, oPre, inst.zone),
  5187. ts = _fixOffset[0],
  5188. o = _fixOffset[1];
  5189. if (millisToAdd !== 0) {
  5190. ts += millisToAdd; // that could have changed the offset by going over a DST, but we want to keep the ts the same
  5191. o = inst.zone.offset(ts);
  5192. }
  5193. return {
  5194. ts: ts,
  5195. o: o
  5196. };
  5197. } // helper useful in turning the results of parsing into real dates
  5198. // by handling the zone options
  5199. function parseDataToDateTime(parsed, parsedZone, opts, format, text) {
  5200. var setZone = opts.setZone,
  5201. zone = opts.zone;
  5202. if (parsed && Object.keys(parsed).length !== 0) {
  5203. var interpretationZone = parsedZone || zone,
  5204. inst = DateTime.fromObject(Object.assign(parsed, opts, {
  5205. zone: interpretationZone,
  5206. // setZone is a valid option in the calling methods, but not in fromObject
  5207. setZone: undefined
  5208. }));
  5209. return setZone ? inst : inst.setZone(zone);
  5210. } else {
  5211. return DateTime.invalid(new Invalid("unparsable", "the input \"" + text + "\" can't be parsed as " + format));
  5212. }
  5213. } // if you want to output a technical format (e.g. RFC 2822), this helper
  5214. // helps handle the details
  5215. function toTechFormat(dt, format, allowZ) {
  5216. if (allowZ === void 0) {
  5217. allowZ = true;
  5218. }
  5219. return dt.isValid ? Formatter.create(Locale.create("en-US"), {
  5220. allowZ: allowZ,
  5221. forceSimple: true
  5222. }).formatDateTimeFromString(dt, format) : null;
  5223. } // technical time formats (e.g. the time part of ISO 8601), take some options
  5224. // and this commonizes their handling
  5225. function toTechTimeFormat(dt, _ref) {
  5226. var _ref$suppressSeconds = _ref.suppressSeconds,
  5227. suppressSeconds = _ref$suppressSeconds === void 0 ? false : _ref$suppressSeconds,
  5228. _ref$suppressMillisec = _ref.suppressMilliseconds,
  5229. suppressMilliseconds = _ref$suppressMillisec === void 0 ? false : _ref$suppressMillisec,
  5230. includeOffset = _ref.includeOffset,
  5231. _ref$includePrefix = _ref.includePrefix,
  5232. includePrefix = _ref$includePrefix === void 0 ? false : _ref$includePrefix,
  5233. _ref$includeZone = _ref.includeZone,
  5234. includeZone = _ref$includeZone === void 0 ? false : _ref$includeZone,
  5235. _ref$spaceZone = _ref.spaceZone,
  5236. spaceZone = _ref$spaceZone === void 0 ? false : _ref$spaceZone,
  5237. _ref$format = _ref.format,
  5238. format = _ref$format === void 0 ? "extended" : _ref$format;
  5239. var fmt = format === "basic" ? "HHmm" : "HH:mm";
  5240. if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
  5241. fmt += format === "basic" ? "ss" : ":ss";
  5242. if (!suppressMilliseconds || dt.millisecond !== 0) {
  5243. fmt += ".SSS";
  5244. }
  5245. }
  5246. if ((includeZone || includeOffset) && spaceZone) {
  5247. fmt += " ";
  5248. }
  5249. if (includeZone) {
  5250. fmt += "z";
  5251. } else if (includeOffset) {
  5252. fmt += format === "basic" ? "ZZZ" : "ZZ";
  5253. }
  5254. var str = toTechFormat(dt, fmt);
  5255. if (includePrefix) {
  5256. str = "T" + str;
  5257. }
  5258. return str;
  5259. } // defaults for unspecified units in the supported calendars
  5260. var defaultUnitValues = {
  5261. month: 1,
  5262. day: 1,
  5263. hour: 0,
  5264. minute: 0,
  5265. second: 0,
  5266. millisecond: 0
  5267. },
  5268. defaultWeekUnitValues = {
  5269. weekNumber: 1,
  5270. weekday: 1,
  5271. hour: 0,
  5272. minute: 0,
  5273. second: 0,
  5274. millisecond: 0
  5275. },
  5276. defaultOrdinalUnitValues = {
  5277. ordinal: 1,
  5278. hour: 0,
  5279. minute: 0,
  5280. second: 0,
  5281. millisecond: 0
  5282. }; // Units in the supported calendars, sorted by bigness
  5283. var orderedUnits$1 = ["year", "month", "day", "hour", "minute", "second", "millisecond"],
  5284. orderedWeekUnits = ["weekYear", "weekNumber", "weekday", "hour", "minute", "second", "millisecond"],
  5285. orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"]; // standardize case and plurality in units
  5286. function normalizeUnit(unit) {
  5287. var normalized = {
  5288. year: "year",
  5289. years: "year",
  5290. month: "month",
  5291. months: "month",
  5292. day: "day",
  5293. days: "day",
  5294. hour: "hour",
  5295. hours: "hour",
  5296. minute: "minute",
  5297. minutes: "minute",
  5298. quarter: "quarter",
  5299. quarters: "quarter",
  5300. second: "second",
  5301. seconds: "second",
  5302. millisecond: "millisecond",
  5303. milliseconds: "millisecond",
  5304. weekday: "weekday",
  5305. weekdays: "weekday",
  5306. weeknumber: "weekNumber",
  5307. weeksnumber: "weekNumber",
  5308. weeknumbers: "weekNumber",
  5309. weekyear: "weekYear",
  5310. weekyears: "weekYear",
  5311. ordinal: "ordinal"
  5312. }[unit.toLowerCase()];
  5313. if (!normalized) throw new InvalidUnitError(unit);
  5314. return normalized;
  5315. } // this is a dumbed down version of fromObject() that runs about 60% faster
  5316. // but doesn't do any validation, makes a bunch of assumptions about what units
  5317. // are present, and so on.
  5318. function quickDT(obj, zone) {
  5319. // assume we have the higher-order units
  5320. for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits$1), _step; !(_step = _iterator()).done;) {
  5321. var u = _step.value;
  5322. if (isUndefined(obj[u])) {
  5323. obj[u] = defaultUnitValues[u];
  5324. }
  5325. }
  5326. var invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
  5327. if (invalid) {
  5328. return DateTime.invalid(invalid);
  5329. }
  5330. var tsNow = Settings.now(),
  5331. offsetProvis = zone.offset(tsNow),
  5332. _objToTS = objToTS(obj, offsetProvis, zone),
  5333. ts = _objToTS[0],
  5334. o = _objToTS[1];
  5335. return new DateTime({
  5336. ts: ts,
  5337. zone: zone,
  5338. o: o
  5339. });
  5340. }
  5341. function diffRelative(start, end, opts) {
  5342. var round = isUndefined(opts.round) ? true : opts.round,
  5343. format = function format(c, unit) {
  5344. c = roundTo(c, round || opts.calendary ? 0 : 2, true);
  5345. var formatter = end.loc.clone(opts).relFormatter(opts);
  5346. return formatter.format(c, unit);
  5347. },
  5348. differ = function differ(unit) {
  5349. if (opts.calendary) {
  5350. if (!end.hasSame(start, unit)) {
  5351. return end.startOf(unit).diff(start.startOf(unit), unit).get(unit);
  5352. } else return 0;
  5353. } else {
  5354. return end.diff(start, unit).get(unit);
  5355. }
  5356. };
  5357. if (opts.unit) {
  5358. return format(differ(opts.unit), opts.unit);
  5359. }
  5360. for (var _iterator2 = _createForOfIteratorHelperLoose(opts.units), _step2; !(_step2 = _iterator2()).done;) {
  5361. var unit = _step2.value;
  5362. var count = differ(unit);
  5363. if (Math.abs(count) >= 1) {
  5364. return format(count, unit);
  5365. }
  5366. }
  5367. return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
  5368. }
  5369. /**
  5370. * A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
  5371. *
  5372. * A DateTime comprises of:
  5373. * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch.
  5374. * * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone).
  5375. * * Configuration properties that effect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`.
  5376. *
  5377. * Here is a brief overview of the most commonly used functionality it provides:
  5378. *
  5379. * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link local}, {@link utc}, and (most flexibly) {@link fromObject}. To create one from a standard string format, use {@link fromISO}, {@link fromHTTP}, and {@link fromRFC2822}. To create one from a custom string format, use {@link fromFormat}. To create one from a native JS date, use {@link fromJSDate}.
  5380. * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link toObject}), use the {@link year}, {@link month},
  5381. * {@link day}, {@link hour}, {@link minute}, {@link second}, {@link millisecond} accessors.
  5382. * * **Week calendar**: For ISO week calendar attributes, see the {@link weekYear}, {@link weekNumber}, and {@link weekday} accessors.
  5383. * * **Configuration** See the {@link locale} and {@link numberingSystem} accessors.
  5384. * * **Transformation**: To transform the DateTime into other DateTimes, use {@link set}, {@link reconfigure}, {@link setZone}, {@link setLocale}, {@link plus}, {@link minus}, {@link endOf}, {@link startOf}, {@link toUTC}, and {@link toLocal}.
  5385. * * **Output**: To convert the DateTime to other representations, use the {@link toRelative}, {@link toRelativeCalendar}, {@link toJSON}, {@link toISO}, {@link toHTTP}, {@link toObject}, {@link toRFC2822}, {@link toString}, {@link toLocaleString}, {@link toFormat}, {@link toMillis} and {@link toJSDate}.
  5386. *
  5387. * There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation.
  5388. */
  5389. var DateTime = /*#__PURE__*/function () {
  5390. /**
  5391. * @access private
  5392. */
  5393. function DateTime(config) {
  5394. var zone = config.zone || Settings.defaultZone;
  5395. var invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
  5396. /**
  5397. * @access private
  5398. */
  5399. this.ts = isUndefined(config.ts) ? Settings.now() : config.ts;
  5400. var c = null,
  5401. o = null;
  5402. if (!invalid) {
  5403. var unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
  5404. if (unchanged) {
  5405. var _ref2 = [config.old.c, config.old.o];
  5406. c = _ref2[0];
  5407. o = _ref2[1];
  5408. } else {
  5409. var ot = zone.offset(this.ts);
  5410. c = tsToObj(this.ts, ot);
  5411. invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
  5412. c = invalid ? null : c;
  5413. o = invalid ? null : ot;
  5414. }
  5415. }
  5416. /**
  5417. * @access private
  5418. */
  5419. this._zone = zone;
  5420. /**
  5421. * @access private
  5422. */
  5423. this.loc = config.loc || Locale.create();
  5424. /**
  5425. * @access private
  5426. */
  5427. this.invalid = invalid;
  5428. /**
  5429. * @access private
  5430. */
  5431. this.weekData = null;
  5432. /**
  5433. * @access private
  5434. */
  5435. this.c = c;
  5436. /**
  5437. * @access private
  5438. */
  5439. this.o = o;
  5440. /**
  5441. * @access private
  5442. */
  5443. this.isLuxonDateTime = true;
  5444. } // CONSTRUCT
  5445. /**
  5446. * Create a DateTime for the current instant, in the system's time zone.
  5447. *
  5448. * Use Settings to override these default values if needed.
  5449. * @example DateTime.now().toISO() //~> now in the ISO format
  5450. * @return {DateTime}
  5451. */
  5452. DateTime.now = function now() {
  5453. return new DateTime({});
  5454. }
  5455. /**
  5456. * Create a local DateTime
  5457. * @param {number} [year] - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used
  5458. * @param {number} [month=1] - The month, 1-indexed
  5459. * @param {number} [day=1] - The day of the month, 1-indexed
  5460. * @param {number} [hour=0] - The hour of the day, in 24-hour time
  5461. * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
  5462. * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
  5463. * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
  5464. * @example DateTime.local() //~> now
  5465. * @example DateTime.local(2017) //~> 2017-01-01T00:00:00
  5466. * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
  5467. * @example DateTime.local(2017, 3, 12) //~> 2017-03-12T00:00:00
  5468. * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
  5469. * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
  5470. * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
  5471. * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
  5472. * @return {DateTime}
  5473. */
  5474. ;
  5475. DateTime.local = function local(year, month, day, hour, minute, second, millisecond) {
  5476. if (isUndefined(year)) {
  5477. return DateTime.now();
  5478. } else {
  5479. return quickDT({
  5480. year: year,
  5481. month: month,
  5482. day: day,
  5483. hour: hour,
  5484. minute: minute,
  5485. second: second,
  5486. millisecond: millisecond
  5487. }, Settings.defaultZone);
  5488. }
  5489. }
  5490. /**
  5491. * Create a DateTime in UTC
  5492. * @param {number} [year] - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used
  5493. * @param {number} [month=1] - The month, 1-indexed
  5494. * @param {number} [day=1] - The day of the month
  5495. * @param {number} [hour=0] - The hour of the day, in 24-hour time
  5496. * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
  5497. * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
  5498. * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
  5499. * @example DateTime.utc() //~> now
  5500. * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
  5501. * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
  5502. * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
  5503. * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
  5504. * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
  5505. * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
  5506. * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765Z
  5507. * @return {DateTime}
  5508. */
  5509. ;
  5510. DateTime.utc = function utc(year, month, day, hour, minute, second, millisecond) {
  5511. if (isUndefined(year)) {
  5512. return new DateTime({
  5513. ts: Settings.now(),
  5514. zone: FixedOffsetZone.utcInstance
  5515. });
  5516. } else {
  5517. return quickDT({
  5518. year: year,
  5519. month: month,
  5520. day: day,
  5521. hour: hour,
  5522. minute: minute,
  5523. second: second,
  5524. millisecond: millisecond
  5525. }, FixedOffsetZone.utcInstance);
  5526. }
  5527. }
  5528. /**
  5529. * Create a DateTime from a JavaScript Date object. Uses the default zone.
  5530. * @param {Date} date - a JavaScript Date object
  5531. * @param {Object} options - configuration options for the DateTime
  5532. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5533. * @return {DateTime}
  5534. */
  5535. ;
  5536. DateTime.fromJSDate = function fromJSDate(date, options) {
  5537. if (options === void 0) {
  5538. options = {};
  5539. }
  5540. var ts = isDate(date) ? date.valueOf() : NaN;
  5541. if (Number.isNaN(ts)) {
  5542. return DateTime.invalid("invalid input");
  5543. }
  5544. var zoneToUse = normalizeZone(options.zone, Settings.defaultZone);
  5545. if (!zoneToUse.isValid) {
  5546. return DateTime.invalid(unsupportedZone(zoneToUse));
  5547. }
  5548. return new DateTime({
  5549. ts: ts,
  5550. zone: zoneToUse,
  5551. loc: Locale.fromObject(options)
  5552. });
  5553. }
  5554. /**
  5555. * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
  5556. * @param {number} milliseconds - a number of milliseconds since 1970 UTC
  5557. * @param {Object} options - configuration options for the DateTime
  5558. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5559. * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
  5560. * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
  5561. * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
  5562. * @return {DateTime}
  5563. */
  5564. ;
  5565. DateTime.fromMillis = function fromMillis(milliseconds, options) {
  5566. if (options === void 0) {
  5567. options = {};
  5568. }
  5569. if (!isNumber(milliseconds)) {
  5570. throw new InvalidArgumentError("fromMillis requires a numerical input, but received a " + typeof milliseconds + " with value " + milliseconds);
  5571. } else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
  5572. // this isn't perfect because because we can still end up out of range because of additional shifting, but it's a start
  5573. return DateTime.invalid("Timestamp out of range");
  5574. } else {
  5575. return new DateTime({
  5576. ts: milliseconds,
  5577. zone: normalizeZone(options.zone, Settings.defaultZone),
  5578. loc: Locale.fromObject(options)
  5579. });
  5580. }
  5581. }
  5582. /**
  5583. * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
  5584. * @param {number} seconds - a number of seconds since 1970 UTC
  5585. * @param {Object} options - configuration options for the DateTime
  5586. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5587. * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
  5588. * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
  5589. * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
  5590. * @return {DateTime}
  5591. */
  5592. ;
  5593. DateTime.fromSeconds = function fromSeconds(seconds, options) {
  5594. if (options === void 0) {
  5595. options = {};
  5596. }
  5597. if (!isNumber(seconds)) {
  5598. throw new InvalidArgumentError("fromSeconds requires a numerical input");
  5599. } else {
  5600. return new DateTime({
  5601. ts: seconds * 1000,
  5602. zone: normalizeZone(options.zone, Settings.defaultZone),
  5603. loc: Locale.fromObject(options)
  5604. });
  5605. }
  5606. }
  5607. /**
  5608. * Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
  5609. * @param {Object} obj - the object to create the DateTime from
  5610. * @param {number} obj.year - a year, such as 1987
  5611. * @param {number} obj.month - a month, 1-12
  5612. * @param {number} obj.day - a day of the month, 1-31, depending on the month
  5613. * @param {number} obj.ordinal - day of the year, 1-365 or 366
  5614. * @param {number} obj.weekYear - an ISO week year
  5615. * @param {number} obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year
  5616. * @param {number} obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
  5617. * @param {number} obj.hour - hour of the day, 0-23
  5618. * @param {number} obj.minute - minute of the hour, 0-59
  5619. * @param {number} obj.second - second of the minute, 0-59
  5620. * @param {number} obj.millisecond - millisecond of the second, 0-999
  5621. * @param {string|Zone} [obj.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone()
  5622. * @param {string} [obj.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5623. * @param {string} obj.outputCalendar - the output calendar to set on the resulting DateTime instance
  5624. * @param {string} obj.numberingSystem - the numbering system to set on the resulting DateTime instance
  5625. * @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
  5626. * @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
  5627. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
  5628. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'utc' }),
  5629. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'local' })
  5630. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'America/New_York' })
  5631. * @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
  5632. * @return {DateTime}
  5633. */
  5634. ;
  5635. DateTime.fromObject = function fromObject(obj) {
  5636. var zoneToUse = normalizeZone(obj.zone, Settings.defaultZone);
  5637. if (!zoneToUse.isValid) {
  5638. return DateTime.invalid(unsupportedZone(zoneToUse));
  5639. }
  5640. var tsNow = Settings.now(),
  5641. offsetProvis = zoneToUse.offset(tsNow),
  5642. normalized = normalizeObject(obj, normalizeUnit, ["zone", "locale", "outputCalendar", "numberingSystem"]),
  5643. containsOrdinal = !isUndefined(normalized.ordinal),
  5644. containsGregorYear = !isUndefined(normalized.year),
  5645. containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
  5646. containsGregor = containsGregorYear || containsGregorMD,
  5647. definiteWeekDef = normalized.weekYear || normalized.weekNumber,
  5648. loc = Locale.fromObject(obj); // cases:
  5649. // just a weekday -> this week's instance of that weekday, no worries
  5650. // (gregorian data or ordinal) + (weekYear or weekNumber) -> error
  5651. // (gregorian month or day) + ordinal -> error
  5652. // otherwise just use weeks or ordinals or gregorian, depending on what's specified
  5653. if ((containsGregor || containsOrdinal) && definiteWeekDef) {
  5654. throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
  5655. }
  5656. if (containsGregorMD && containsOrdinal) {
  5657. throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
  5658. }
  5659. var useWeekData = definiteWeekDef || normalized.weekday && !containsGregor; // configure ourselves to deal with gregorian dates or week stuff
  5660. var units,
  5661. defaultValues,
  5662. objNow = tsToObj(tsNow, offsetProvis);
  5663. if (useWeekData) {
  5664. units = orderedWeekUnits;
  5665. defaultValues = defaultWeekUnitValues;
  5666. objNow = gregorianToWeek(objNow);
  5667. } else if (containsOrdinal) {
  5668. units = orderedOrdinalUnits;
  5669. defaultValues = defaultOrdinalUnitValues;
  5670. objNow = gregorianToOrdinal(objNow);
  5671. } else {
  5672. units = orderedUnits$1;
  5673. defaultValues = defaultUnitValues;
  5674. } // set default values for missing stuff
  5675. var foundFirst = false;
  5676. for (var _iterator3 = _createForOfIteratorHelperLoose(units), _step3; !(_step3 = _iterator3()).done;) {
  5677. var u = _step3.value;
  5678. var v = normalized[u];
  5679. if (!isUndefined(v)) {
  5680. foundFirst = true;
  5681. } else if (foundFirst) {
  5682. normalized[u] = defaultValues[u];
  5683. } else {
  5684. normalized[u] = objNow[u];
  5685. }
  5686. } // make sure the values we have are in range
  5687. var higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized),
  5688. invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
  5689. if (invalid) {
  5690. return DateTime.invalid(invalid);
  5691. } // compute the actual time
  5692. var gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized,
  5693. _objToTS2 = objToTS(gregorian, offsetProvis, zoneToUse),
  5694. tsFinal = _objToTS2[0],
  5695. offsetFinal = _objToTS2[1],
  5696. inst = new DateTime({
  5697. ts: tsFinal,
  5698. zone: zoneToUse,
  5699. o: offsetFinal,
  5700. loc: loc
  5701. }); // gregorian data + weekday serves only to validate
  5702. if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
  5703. return DateTime.invalid("mismatched weekday", "you can't specify both a weekday of " + normalized.weekday + " and a date of " + inst.toISO());
  5704. }
  5705. return inst;
  5706. }
  5707. /**
  5708. * Create a DateTime from an ISO 8601 string
  5709. * @param {string} text - the ISO string
  5710. * @param {Object} opts - options to affect the creation
  5711. * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the time to this zone
  5712. * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
  5713. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5714. * @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance
  5715. * @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance
  5716. * @example DateTime.fromISO('2016-05-25T09:08:34.123')
  5717. * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
  5718. * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
  5719. * @example DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})
  5720. * @example DateTime.fromISO('2016-W05-4')
  5721. * @return {DateTime}
  5722. */
  5723. ;
  5724. DateTime.fromISO = function fromISO(text, opts) {
  5725. if (opts === void 0) {
  5726. opts = {};
  5727. }
  5728. var _parseISODate = parseISODate(text),
  5729. vals = _parseISODate[0],
  5730. parsedZone = _parseISODate[1];
  5731. return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text);
  5732. }
  5733. /**
  5734. * Create a DateTime from an RFC 2822 string
  5735. * @param {string} text - the RFC 2822 string
  5736. * @param {Object} opts - options to affect the creation
  5737. * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since the offset is always specified in the string itself, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
  5738. * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
  5739. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5740. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5741. * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
  5742. * @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
  5743. * @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
  5744. * @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
  5745. * @return {DateTime}
  5746. */
  5747. ;
  5748. DateTime.fromRFC2822 = function fromRFC2822(text, opts) {
  5749. if (opts === void 0) {
  5750. opts = {};
  5751. }
  5752. var _parseRFC2822Date = parseRFC2822Date(text),
  5753. vals = _parseRFC2822Date[0],
  5754. parsedZone = _parseRFC2822Date[1];
  5755. return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text);
  5756. }
  5757. /**
  5758. * Create a DateTime from an HTTP header date
  5759. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
  5760. * @param {string} text - the HTTP header date
  5761. * @param {Object} opts - options to affect the creation
  5762. * @param {string|Zone} [opts.zone='local'] - convert the time to this zone. Since HTTP dates are always in UTC, this has no effect on the interpretation of string, merely the zone the resulting DateTime is expressed in.
  5763. * @param {boolean} [opts.setZone=false] - override the zone with the fixed-offset zone specified in the string. For HTTP dates, this is always UTC, so this option is equivalent to setting the `zone` option to 'utc', but this option is included for consistency with similar methods.
  5764. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5765. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5766. * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
  5767. * @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
  5768. * @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
  5769. * @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
  5770. * @return {DateTime}
  5771. */
  5772. ;
  5773. DateTime.fromHTTP = function fromHTTP(text, opts) {
  5774. if (opts === void 0) {
  5775. opts = {};
  5776. }
  5777. var _parseHTTPDate = parseHTTPDate(text),
  5778. vals = _parseHTTPDate[0],
  5779. parsedZone = _parseHTTPDate[1];
  5780. return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
  5781. }
  5782. /**
  5783. * Create a DateTime from an input string and format string.
  5784. * Defaults to en-US if no locale has been specified, regardless of the system's locale.
  5785. * @see https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens
  5786. * @param {string} text - the string to parse
  5787. * @param {string} fmt - the format the string is expected to be in (see the link below for the formats)
  5788. * @param {Object} opts - options to affect the creation
  5789. * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
  5790. * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
  5791. * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
  5792. * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
  5793. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5794. * @return {DateTime}
  5795. */
  5796. ;
  5797. DateTime.fromFormat = function fromFormat(text, fmt, opts) {
  5798. if (opts === void 0) {
  5799. opts = {};
  5800. }
  5801. if (isUndefined(text) || isUndefined(fmt)) {
  5802. throw new InvalidArgumentError("fromFormat requires an input string and a format");
  5803. }
  5804. var _opts = opts,
  5805. _opts$locale = _opts.locale,
  5806. locale = _opts$locale === void 0 ? null : _opts$locale,
  5807. _opts$numberingSystem = _opts.numberingSystem,
  5808. numberingSystem = _opts$numberingSystem === void 0 ? null : _opts$numberingSystem,
  5809. localeToUse = Locale.fromOpts({
  5810. locale: locale,
  5811. numberingSystem: numberingSystem,
  5812. defaultToEN: true
  5813. }),
  5814. _parseFromTokens = parseFromTokens(localeToUse, text, fmt),
  5815. vals = _parseFromTokens[0],
  5816. parsedZone = _parseFromTokens[1],
  5817. invalid = _parseFromTokens[2];
  5818. if (invalid) {
  5819. return DateTime.invalid(invalid);
  5820. } else {
  5821. return parseDataToDateTime(vals, parsedZone, opts, "format " + fmt, text);
  5822. }
  5823. }
  5824. /**
  5825. * @deprecated use fromFormat instead
  5826. */
  5827. ;
  5828. DateTime.fromString = function fromString(text, fmt, opts) {
  5829. if (opts === void 0) {
  5830. opts = {};
  5831. }
  5832. return DateTime.fromFormat(text, fmt, opts);
  5833. }
  5834. /**
  5835. * Create a DateTime from a SQL date, time, or datetime
  5836. * Defaults to en-US if no locale has been specified, regardless of the system's locale
  5837. * @param {string} text - the string to parse
  5838. * @param {Object} opts - options to affect the creation
  5839. * @param {string|Zone} [opts.zone='local'] - use this zone if no offset is specified in the input string itself. Will also convert the DateTime to this zone
  5840. * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
  5841. * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
  5842. * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
  5843. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5844. * @example DateTime.fromSQL('2017-05-15')
  5845. * @example DateTime.fromSQL('2017-05-15 09:12:34')
  5846. * @example DateTime.fromSQL('2017-05-15 09:12:34.342')
  5847. * @example DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')
  5848. * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')
  5849. * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })
  5850. * @example DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })
  5851. * @example DateTime.fromSQL('09:12:34.342')
  5852. * @return {DateTime}
  5853. */
  5854. ;
  5855. DateTime.fromSQL = function fromSQL(text, opts) {
  5856. if (opts === void 0) {
  5857. opts = {};
  5858. }
  5859. var _parseSQL = parseSQL(text),
  5860. vals = _parseSQL[0],
  5861. parsedZone = _parseSQL[1];
  5862. return parseDataToDateTime(vals, parsedZone, opts, "SQL", text);
  5863. }
  5864. /**
  5865. * Create an invalid DateTime.
  5866. * @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
  5867. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  5868. * @return {DateTime}
  5869. */
  5870. ;
  5871. DateTime.invalid = function invalid(reason, explanation) {
  5872. if (explanation === void 0) {
  5873. explanation = null;
  5874. }
  5875. if (!reason) {
  5876. throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
  5877. }
  5878. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  5879. if (Settings.throwOnInvalid) {
  5880. throw new InvalidDateTimeError(invalid);
  5881. } else {
  5882. return new DateTime({
  5883. invalid: invalid
  5884. });
  5885. }
  5886. }
  5887. /**
  5888. * Check if an object is a DateTime. Works across context boundaries
  5889. * @param {object} o
  5890. * @return {boolean}
  5891. */
  5892. ;
  5893. DateTime.isDateTime = function isDateTime(o) {
  5894. return o && o.isLuxonDateTime || false;
  5895. } // INFO
  5896. /**
  5897. * Get the value of unit.
  5898. * @param {string} unit - a unit such as 'minute' or 'day'
  5899. * @example DateTime.local(2017, 7, 4).get('month'); //=> 7
  5900. * @example DateTime.local(2017, 7, 4).get('day'); //=> 4
  5901. * @return {number}
  5902. */
  5903. ;
  5904. var _proto = DateTime.prototype;
  5905. _proto.get = function get(unit) {
  5906. return this[unit];
  5907. }
  5908. /**
  5909. * Returns whether the DateTime is valid. Invalid DateTimes occur when:
  5910. * * The DateTime was created from invalid calendar information, such as the 13th month or February 30
  5911. * * The DateTime was created by an operation on another invalid date
  5912. * @type {boolean}
  5913. */
  5914. ;
  5915. /**
  5916. * Returns the resolved Intl options for this DateTime.
  5917. * This is useful in understanding the behavior of formatting methods
  5918. * @param {Object} opts - the same options as toLocaleString
  5919. * @return {Object}
  5920. */
  5921. _proto.resolvedLocaleOpts = function resolvedLocaleOpts(opts) {
  5922. if (opts === void 0) {
  5923. opts = {};
  5924. }
  5925. var _Formatter$create$res = Formatter.create(this.loc.clone(opts), opts).resolvedOptions(this),
  5926. locale = _Formatter$create$res.locale,
  5927. numberingSystem = _Formatter$create$res.numberingSystem,
  5928. calendar = _Formatter$create$res.calendar;
  5929. return {
  5930. locale: locale,
  5931. numberingSystem: numberingSystem,
  5932. outputCalendar: calendar
  5933. };
  5934. } // TRANSFORM
  5935. /**
  5936. * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
  5937. *
  5938. * Equivalent to {@link setZone}('utc')
  5939. * @param {number} [offset=0] - optionally, an offset from UTC in minutes
  5940. * @param {Object} [opts={}] - options to pass to `setZone()`
  5941. * @return {DateTime}
  5942. */
  5943. ;
  5944. _proto.toUTC = function toUTC(offset, opts) {
  5945. if (offset === void 0) {
  5946. offset = 0;
  5947. }
  5948. if (opts === void 0) {
  5949. opts = {};
  5950. }
  5951. return this.setZone(FixedOffsetZone.instance(offset), opts);
  5952. }
  5953. /**
  5954. * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.
  5955. *
  5956. * Equivalent to `setZone('local')`
  5957. * @return {DateTime}
  5958. */
  5959. ;
  5960. _proto.toLocal = function toLocal() {
  5961. return this.setZone(Settings.defaultZone);
  5962. }
  5963. /**
  5964. * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
  5965. *
  5966. * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link plus}. You may wish to use {@link toLocal} and {@link toUTC} which provide simple convenience wrappers for commonly used zones.
  5967. * @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link Zone} class.
  5968. * @param {Object} opts - options
  5969. * @param {boolean} [opts.keepLocalTime=false] - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this.
  5970. * @return {DateTime}
  5971. */
  5972. ;
  5973. _proto.setZone = function setZone(zone, _temp) {
  5974. var _ref3 = _temp === void 0 ? {} : _temp,
  5975. _ref3$keepLocalTime = _ref3.keepLocalTime,
  5976. keepLocalTime = _ref3$keepLocalTime === void 0 ? false : _ref3$keepLocalTime,
  5977. _ref3$keepCalendarTim = _ref3.keepCalendarTime,
  5978. keepCalendarTime = _ref3$keepCalendarTim === void 0 ? false : _ref3$keepCalendarTim;
  5979. zone = normalizeZone(zone, Settings.defaultZone);
  5980. if (zone.equals(this.zone)) {
  5981. return this;
  5982. } else if (!zone.isValid) {
  5983. return DateTime.invalid(unsupportedZone(zone));
  5984. } else {
  5985. var newTS = this.ts;
  5986. if (keepLocalTime || keepCalendarTime) {
  5987. var offsetGuess = zone.offset(this.ts);
  5988. var asObj = this.toObject();
  5989. var _objToTS3 = objToTS(asObj, offsetGuess, zone);
  5990. newTS = _objToTS3[0];
  5991. }
  5992. return clone$1(this, {
  5993. ts: newTS,
  5994. zone: zone
  5995. });
  5996. }
  5997. }
  5998. /**
  5999. * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
  6000. * @param {Object} properties - the properties to set
  6001. * @example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
  6002. * @return {DateTime}
  6003. */
  6004. ;
  6005. _proto.reconfigure = function reconfigure(_temp2) {
  6006. var _ref4 = _temp2 === void 0 ? {} : _temp2,
  6007. locale = _ref4.locale,
  6008. numberingSystem = _ref4.numberingSystem,
  6009. outputCalendar = _ref4.outputCalendar;
  6010. var loc = this.loc.clone({
  6011. locale: locale,
  6012. numberingSystem: numberingSystem,
  6013. outputCalendar: outputCalendar
  6014. });
  6015. return clone$1(this, {
  6016. loc: loc
  6017. });
  6018. }
  6019. /**
  6020. * "Set" the locale. Returns a newly-constructed DateTime.
  6021. * Just a convenient alias for reconfigure({ locale })
  6022. * @example DateTime.local(2017, 5, 25).setLocale('en-GB')
  6023. * @return {DateTime}
  6024. */
  6025. ;
  6026. _proto.setLocale = function setLocale(locale) {
  6027. return this.reconfigure({
  6028. locale: locale
  6029. });
  6030. }
  6031. /**
  6032. * "Set" the values of specified units. Returns a newly-constructed DateTime.
  6033. * You can only set units with this method; for "setting" metadata, see {@link reconfigure} and {@link setZone}.
  6034. * @param {Object} values - a mapping of units to numbers
  6035. * @example dt.set({ year: 2017 })
  6036. * @example dt.set({ hour: 8, minute: 30 })
  6037. * @example dt.set({ weekday: 5 })
  6038. * @example dt.set({ year: 2005, ordinal: 234 })
  6039. * @return {DateTime}
  6040. */
  6041. ;
  6042. _proto.set = function set(values) {
  6043. if (!this.isValid) return this;
  6044. var normalized = normalizeObject(values, normalizeUnit, []),
  6045. settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday),
  6046. containsOrdinal = !isUndefined(normalized.ordinal),
  6047. containsGregorYear = !isUndefined(normalized.year),
  6048. containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
  6049. containsGregor = containsGregorYear || containsGregorMD,
  6050. definiteWeekDef = normalized.weekYear || normalized.weekNumber;
  6051. if ((containsGregor || containsOrdinal) && definiteWeekDef) {
  6052. throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
  6053. }
  6054. if (containsGregorMD && containsOrdinal) {
  6055. throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
  6056. }
  6057. var mixed;
  6058. if (settingWeekStuff) {
  6059. mixed = weekToGregorian(Object.assign(gregorianToWeek(this.c), normalized));
  6060. } else if (!isUndefined(normalized.ordinal)) {
  6061. mixed = ordinalToGregorian(Object.assign(gregorianToOrdinal(this.c), normalized));
  6062. } else {
  6063. mixed = Object.assign(this.toObject(), normalized); // if we didn't set the day but we ended up on an overflow date,
  6064. // use the last day of the right month
  6065. if (isUndefined(normalized.day)) {
  6066. mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
  6067. }
  6068. }
  6069. var _objToTS4 = objToTS(mixed, this.o, this.zone),
  6070. ts = _objToTS4[0],
  6071. o = _objToTS4[1];
  6072. return clone$1(this, {
  6073. ts: ts,
  6074. o: o
  6075. });
  6076. }
  6077. /**
  6078. * Add a period of time to this DateTime and return the resulting DateTime
  6079. *
  6080. * Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, `dt.plus({ hours: 24 })` may result in a different time than `dt.plus({ days: 1 })` if there's a DST shift in between.
  6081. * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  6082. * @example DateTime.now().plus(123) //~> in 123 milliseconds
  6083. * @example DateTime.now().plus({ minutes: 15 }) //~> in 15 minutes
  6084. * @example DateTime.now().plus({ days: 1 }) //~> this time tomorrow
  6085. * @example DateTime.now().plus({ days: -1 }) //~> this time yesterday
  6086. * @example DateTime.now().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min
  6087. * @example DateTime.now().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min
  6088. * @return {DateTime}
  6089. */
  6090. ;
  6091. _proto.plus = function plus(duration) {
  6092. if (!this.isValid) return this;
  6093. var dur = friendlyDuration(duration);
  6094. return clone$1(this, adjustTime(this, dur));
  6095. }
  6096. /**
  6097. * Subtract a period of time to this DateTime and return the resulting DateTime
  6098. * See {@link plus}
  6099. * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  6100. @return {DateTime}
  6101. */
  6102. ;
  6103. _proto.minus = function minus(duration) {
  6104. if (!this.isValid) return this;
  6105. var dur = friendlyDuration(duration).negate();
  6106. return clone$1(this, adjustTime(this, dur));
  6107. }
  6108. /**
  6109. * "Set" this DateTime to the beginning of a unit of time.
  6110. * @param {string} unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
  6111. * @example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'
  6112. * @example DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'
  6113. * @example DateTime.local(2014, 3, 3).startOf('week').toISODate(); //=> '2014-03-03', weeks always start on Mondays
  6114. * @example DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'
  6115. * @example DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'
  6116. * @return {DateTime}
  6117. */
  6118. ;
  6119. _proto.startOf = function startOf(unit) {
  6120. if (!this.isValid) return this;
  6121. var o = {},
  6122. normalizedUnit = Duration.normalizeUnit(unit);
  6123. switch (normalizedUnit) {
  6124. case "years":
  6125. o.month = 1;
  6126. // falls through
  6127. case "quarters":
  6128. case "months":
  6129. o.day = 1;
  6130. // falls through
  6131. case "weeks":
  6132. case "days":
  6133. o.hour = 0;
  6134. // falls through
  6135. case "hours":
  6136. o.minute = 0;
  6137. // falls through
  6138. case "minutes":
  6139. o.second = 0;
  6140. // falls through
  6141. case "seconds":
  6142. o.millisecond = 0;
  6143. break;
  6144. // no default, invalid units throw in normalizeUnit()
  6145. }
  6146. if (normalizedUnit === "weeks") {
  6147. o.weekday = 1;
  6148. }
  6149. if (normalizedUnit === "quarters") {
  6150. var q = Math.ceil(this.month / 3);
  6151. o.month = (q - 1) * 3 + 1;
  6152. }
  6153. return this.set(o);
  6154. }
  6155. /**
  6156. * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time
  6157. * @param {string} unit - The unit to go to the end of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
  6158. * @example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'
  6159. * @example DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'
  6160. * @example DateTime.local(2014, 3, 3).endOf('week').toISO(); // => '2014-03-09T23:59:59.999-05:00', weeks start on Mondays
  6161. * @example DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'
  6162. * @example DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'
  6163. * @return {DateTime}
  6164. */
  6165. ;
  6166. _proto.endOf = function endOf(unit) {
  6167. var _this$plus;
  6168. return this.isValid ? this.plus((_this$plus = {}, _this$plus[unit] = 1, _this$plus)).startOf(unit).minus(1) : this;
  6169. } // OUTPUT
  6170. /**
  6171. * Returns a string representation of this DateTime formatted according to the specified format string.
  6172. * **You may not want this.** See {@link toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens).
  6173. * Defaults to en-US if no locale has been specified, regardless of the system's locale.
  6174. * @see https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens
  6175. * @param {string} fmt - the format string
  6176. * @param {Object} opts - opts to override the configuration options
  6177. * @example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
  6178. * @example DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
  6179. * @example DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
  6180. * @example DateTime.now().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'
  6181. * @return {string}
  6182. */
  6183. ;
  6184. _proto.toFormat = function toFormat(fmt, opts) {
  6185. if (opts === void 0) {
  6186. opts = {};
  6187. }
  6188. return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID$2;
  6189. }
  6190. /**
  6191. * Returns a localized string representing this date. Accepts the same options as the Intl.DateTimeFormat constructor and any presets defined by Luxon, such as `DateTime.DATE_FULL` or `DateTime.TIME_SIMPLE`.
  6192. * The exact behavior of this method is browser-specific, but in general it will return an appropriate representation
  6193. * of the DateTime in the assigned locale.
  6194. * Defaults to the system's locale if no locale has been specified
  6195. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  6196. * @param opts {Object} - Intl.DateTimeFormat constructor options and configuration options
  6197. * @example DateTime.now().toLocaleString(); //=> 4/20/2017
  6198. * @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
  6199. * @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
  6200. * @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
  6201. * @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
  6202. * @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
  6203. * @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
  6204. * @example DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
  6205. * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hour12: false }); //=> '11:32'
  6206. * @return {string}
  6207. */
  6208. ;
  6209. _proto.toLocaleString = function toLocaleString(opts) {
  6210. if (opts === void 0) {
  6211. opts = DATE_SHORT;
  6212. }
  6213. return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTime(this) : INVALID$2;
  6214. }
  6215. /**
  6216. * Returns an array of format "parts", meaning individual tokens along with metadata. This is allows callers to post-process individual sections of the formatted output.
  6217. * Defaults to the system's locale if no locale has been specified
  6218. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts
  6219. * @param opts {Object} - Intl.DateTimeFormat constructor options, same as `toLocaleString`.
  6220. * @example DateTime.now().toLocaleParts(); //=> [
  6221. * //=> { type: 'day', value: '25' },
  6222. * //=> { type: 'literal', value: '/' },
  6223. * //=> { type: 'month', value: '05' },
  6224. * //=> { type: 'literal', value: '/' },
  6225. * //=> { type: 'year', value: '1982' }
  6226. * //=> ]
  6227. */
  6228. ;
  6229. _proto.toLocaleParts = function toLocaleParts(opts) {
  6230. if (opts === void 0) {
  6231. opts = {};
  6232. }
  6233. return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
  6234. }
  6235. /**
  6236. * Returns an ISO 8601-compliant string representation of this DateTime
  6237. * @param {Object} opts - options
  6238. * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
  6239. * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
  6240. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6241. * @param {string} [opts.format='extended'] - choose between the basic and extended format
  6242. * @example DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
  6243. * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
  6244. * @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
  6245. * @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
  6246. * @return {string}
  6247. */
  6248. ;
  6249. _proto.toISO = function toISO(opts) {
  6250. if (opts === void 0) {
  6251. opts = {};
  6252. }
  6253. if (!this.isValid) {
  6254. return null;
  6255. }
  6256. return this.toISODate(opts) + "T" + this.toISOTime(opts);
  6257. }
  6258. /**
  6259. * Returns an ISO 8601-compliant string representation of this DateTime's date component
  6260. * @param {Object} opts - options
  6261. * @param {string} [opts.format='extended'] - choose between the basic and extended format
  6262. * @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
  6263. * @example DateTime.utc(1982, 5, 25).toISODate({ format: 'basic' }) //=> '19820525'
  6264. * @return {string}
  6265. */
  6266. ;
  6267. _proto.toISODate = function toISODate(_temp3) {
  6268. var _ref5 = _temp3 === void 0 ? {} : _temp3,
  6269. _ref5$format = _ref5.format,
  6270. format = _ref5$format === void 0 ? "extended" : _ref5$format;
  6271. var fmt = format === "basic" ? "yyyyMMdd" : "yyyy-MM-dd";
  6272. if (this.year > 9999) {
  6273. fmt = "+" + fmt;
  6274. }
  6275. return toTechFormat(this, fmt);
  6276. }
  6277. /**
  6278. * Returns an ISO 8601-compliant string representation of this DateTime's week date
  6279. * @example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'
  6280. * @return {string}
  6281. */
  6282. ;
  6283. _proto.toISOWeekDate = function toISOWeekDate() {
  6284. return toTechFormat(this, "kkkk-'W'WW-c");
  6285. }
  6286. /**
  6287. * Returns an ISO 8601-compliant string representation of this DateTime's time component
  6288. * @param {Object} opts - options
  6289. * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
  6290. * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
  6291. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6292. * @param {boolean} [opts.includePrefix=false] - include the `T` prefix
  6293. * @param {string} [opts.format='extended'] - choose between the basic and extended format
  6294. * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
  6295. * @example DateTime.utc().set({ hour: 7, minute: 34, seconds: 0, milliseconds: 0 }).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
  6296. * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ format: 'basic' }) //=> '073419.361Z'
  6297. * @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime({ includePrefix: true }) //=> 'T07:34:19.361Z'
  6298. * @return {string}
  6299. */
  6300. ;
  6301. _proto.toISOTime = function toISOTime(_temp4) {
  6302. var _ref6 = _temp4 === void 0 ? {} : _temp4,
  6303. _ref6$suppressMillise = _ref6.suppressMilliseconds,
  6304. suppressMilliseconds = _ref6$suppressMillise === void 0 ? false : _ref6$suppressMillise,
  6305. _ref6$suppressSeconds = _ref6.suppressSeconds,
  6306. suppressSeconds = _ref6$suppressSeconds === void 0 ? false : _ref6$suppressSeconds,
  6307. _ref6$includeOffset = _ref6.includeOffset,
  6308. includeOffset = _ref6$includeOffset === void 0 ? true : _ref6$includeOffset,
  6309. _ref6$includePrefix = _ref6.includePrefix,
  6310. includePrefix = _ref6$includePrefix === void 0 ? false : _ref6$includePrefix,
  6311. _ref6$format = _ref6.format,
  6312. format = _ref6$format === void 0 ? "extended" : _ref6$format;
  6313. return toTechTimeFormat(this, {
  6314. suppressSeconds: suppressSeconds,
  6315. suppressMilliseconds: suppressMilliseconds,
  6316. includeOffset: includeOffset,
  6317. includePrefix: includePrefix,
  6318. format: format
  6319. });
  6320. }
  6321. /**
  6322. * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC
  6323. * @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
  6324. * @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
  6325. * @return {string}
  6326. */
  6327. ;
  6328. _proto.toRFC2822 = function toRFC2822() {
  6329. return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
  6330. }
  6331. /**
  6332. * Returns a string representation of this DateTime appropriate for use in HTTP headers.
  6333. * Specifically, the string conforms to RFC 1123.
  6334. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
  6335. * @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
  6336. * @example DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'
  6337. * @return {string}
  6338. */
  6339. ;
  6340. _proto.toHTTP = function toHTTP() {
  6341. return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
  6342. }
  6343. /**
  6344. * Returns a string representation of this DateTime appropriate for use in SQL Date
  6345. * @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
  6346. * @return {string}
  6347. */
  6348. ;
  6349. _proto.toSQLDate = function toSQLDate() {
  6350. return toTechFormat(this, "yyyy-MM-dd");
  6351. }
  6352. /**
  6353. * Returns a string representation of this DateTime appropriate for use in SQL Time
  6354. * @param {Object} opts - options
  6355. * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
  6356. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6357. * @example DateTime.utc().toSQL() //=> '05:15:16.345'
  6358. * @example DateTime.now().toSQL() //=> '05:15:16.345 -04:00'
  6359. * @example DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'
  6360. * @example DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
  6361. * @return {string}
  6362. */
  6363. ;
  6364. _proto.toSQLTime = function toSQLTime(_temp5) {
  6365. var _ref7 = _temp5 === void 0 ? {} : _temp5,
  6366. _ref7$includeOffset = _ref7.includeOffset,
  6367. includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset,
  6368. _ref7$includeZone = _ref7.includeZone,
  6369. includeZone = _ref7$includeZone === void 0 ? false : _ref7$includeZone;
  6370. return toTechTimeFormat(this, {
  6371. includeOffset: includeOffset,
  6372. includeZone: includeZone,
  6373. spaceZone: true
  6374. });
  6375. }
  6376. /**
  6377. * Returns a string representation of this DateTime appropriate for use in SQL DateTime
  6378. * @param {Object} opts - options
  6379. * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
  6380. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6381. * @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
  6382. * @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
  6383. * @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
  6384. * @example DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'
  6385. * @return {string}
  6386. */
  6387. ;
  6388. _proto.toSQL = function toSQL(opts) {
  6389. if (opts === void 0) {
  6390. opts = {};
  6391. }
  6392. if (!this.isValid) {
  6393. return null;
  6394. }
  6395. return this.toSQLDate() + " " + this.toSQLTime(opts);
  6396. }
  6397. /**
  6398. * Returns a string representation of this DateTime appropriate for debugging
  6399. * @return {string}
  6400. */
  6401. ;
  6402. _proto.toString = function toString() {
  6403. return this.isValid ? this.toISO() : INVALID$2;
  6404. }
  6405. /**
  6406. * Returns the epoch milliseconds of this DateTime. Alias of {@link toMillis}
  6407. * @return {number}
  6408. */
  6409. ;
  6410. _proto.valueOf = function valueOf() {
  6411. return this.toMillis();
  6412. }
  6413. /**
  6414. * Returns the epoch milliseconds of this DateTime.
  6415. * @return {number}
  6416. */
  6417. ;
  6418. _proto.toMillis = function toMillis() {
  6419. return this.isValid ? this.ts : NaN;
  6420. }
  6421. /**
  6422. * Returns the epoch seconds of this DateTime.
  6423. * @return {number}
  6424. */
  6425. ;
  6426. _proto.toSeconds = function toSeconds() {
  6427. return this.isValid ? this.ts / 1000 : NaN;
  6428. }
  6429. /**
  6430. * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
  6431. * @return {string}
  6432. */
  6433. ;
  6434. _proto.toJSON = function toJSON() {
  6435. return this.toISO();
  6436. }
  6437. /**
  6438. * Returns a BSON serializable equivalent to this DateTime.
  6439. * @return {Date}
  6440. */
  6441. ;
  6442. _proto.toBSON = function toBSON() {
  6443. return this.toJSDate();
  6444. }
  6445. /**
  6446. * Returns a JavaScript object with this DateTime's year, month, day, and so on.
  6447. * @param opts - options for generating the object
  6448. * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
  6449. * @example DateTime.now().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
  6450. * @return {Object}
  6451. */
  6452. ;
  6453. _proto.toObject = function toObject(opts) {
  6454. if (opts === void 0) {
  6455. opts = {};
  6456. }
  6457. if (!this.isValid) return {};
  6458. var base = Object.assign({}, this.c);
  6459. if (opts.includeConfig) {
  6460. base.outputCalendar = this.outputCalendar;
  6461. base.numberingSystem = this.loc.numberingSystem;
  6462. base.locale = this.loc.locale;
  6463. }
  6464. return base;
  6465. }
  6466. /**
  6467. * Returns a JavaScript Date equivalent to this DateTime.
  6468. * @return {Date}
  6469. */
  6470. ;
  6471. _proto.toJSDate = function toJSDate() {
  6472. return new Date(this.isValid ? this.ts : NaN);
  6473. } // COMPARE
  6474. /**
  6475. * Return the difference between two DateTimes as a Duration.
  6476. * @param {DateTime} otherDateTime - the DateTime to compare this one to
  6477. * @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration.
  6478. * @param {Object} opts - options that affect the creation of the Duration
  6479. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  6480. * @example
  6481. * var i1 = DateTime.fromISO('1982-05-25T09:45'),
  6482. * i2 = DateTime.fromISO('1983-10-14T10:30');
  6483. * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 }
  6484. * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 }
  6485. * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 }
  6486. * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 }
  6487. * @return {Duration}
  6488. */
  6489. ;
  6490. _proto.diff = function diff(otherDateTime, unit, opts) {
  6491. if (unit === void 0) {
  6492. unit = "milliseconds";
  6493. }
  6494. if (opts === void 0) {
  6495. opts = {};
  6496. }
  6497. if (!this.isValid || !otherDateTime.isValid) {
  6498. return Duration.invalid(this.invalid || otherDateTime.invalid, "created by diffing an invalid DateTime");
  6499. }
  6500. var durOpts = Object.assign({
  6501. locale: this.locale,
  6502. numberingSystem: this.numberingSystem
  6503. }, opts);
  6504. var units = maybeArray(unit).map(Duration.normalizeUnit),
  6505. otherIsLater = otherDateTime.valueOf() > this.valueOf(),
  6506. earlier = otherIsLater ? this : otherDateTime,
  6507. later = otherIsLater ? otherDateTime : this,
  6508. diffed = _diff(earlier, later, units, durOpts);
  6509. return otherIsLater ? diffed.negate() : diffed;
  6510. }
  6511. /**
  6512. * Return the difference between this DateTime and right now.
  6513. * See {@link diff}
  6514. * @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration
  6515. * @param {Object} opts - options that affect the creation of the Duration
  6516. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  6517. * @return {Duration}
  6518. */
  6519. ;
  6520. _proto.diffNow = function diffNow(unit, opts) {
  6521. if (unit === void 0) {
  6522. unit = "milliseconds";
  6523. }
  6524. if (opts === void 0) {
  6525. opts = {};
  6526. }
  6527. return this.diff(DateTime.now(), unit, opts);
  6528. }
  6529. /**
  6530. * Return an Interval spanning between this DateTime and another DateTime
  6531. * @param {DateTime} otherDateTime - the other end point of the Interval
  6532. * @return {Interval}
  6533. */
  6534. ;
  6535. _proto.until = function until(otherDateTime) {
  6536. return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
  6537. }
  6538. /**
  6539. * Return whether this DateTime is in the same unit of time as another DateTime.
  6540. * Higher-order units must also be identical for this function to return `true`.
  6541. * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link setZone} to convert one of the dates if needed.
  6542. * @param {DateTime} otherDateTime - the other DateTime
  6543. * @param {string} unit - the unit of time to check sameness on
  6544. * @example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
  6545. * @return {boolean}
  6546. */
  6547. ;
  6548. _proto.hasSame = function hasSame(otherDateTime, unit) {
  6549. if (!this.isValid) return false;
  6550. var inputMs = otherDateTime.valueOf();
  6551. var otherZoneDateTime = this.setZone(otherDateTime.zone, {
  6552. keepLocalTime: true
  6553. });
  6554. return otherZoneDateTime.startOf(unit) <= inputMs && inputMs <= otherZoneDateTime.endOf(unit);
  6555. }
  6556. /**
  6557. * Equality check
  6558. * Two DateTimes are equal iff they represent the same millisecond, have the same zone and location, and are both valid.
  6559. * To compare just the millisecond values, use `+dt1 === +dt2`.
  6560. * @param {DateTime} other - the other DateTime
  6561. * @return {boolean}
  6562. */
  6563. ;
  6564. _proto.equals = function equals(other) {
  6565. return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
  6566. }
  6567. /**
  6568. * Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
  6569. * platform supports Intl.RelativeTimeFormat. Rounds down by default.
  6570. * @param {Object} options - options that affect the output
  6571. * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
  6572. * @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow"
  6573. * @param {string|string[]} options.unit - use a specific unit or array of units; if omitted, or an array, the method will pick the best unit. Use an array or one of "years", "quarters", "months", "weeks", "days", "hours", "minutes", or "seconds"
  6574. * @param {boolean} [options.round=true] - whether to round the numbers in the output.
  6575. * @param {number} [options.padding=0] - padding in milliseconds. This allows you to round up the result if it fits inside the threshold. Don't use in combination with {round: false} because the decimal output will include the padding.
  6576. * @param {string} options.locale - override the locale of this DateTime
  6577. * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
  6578. * @example DateTime.now().plus({ days: 1 }).toRelative() //=> "in 1 day"
  6579. * @example DateTime.now().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"
  6580. * @example DateTime.now().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"
  6581. * @example DateTime.now().minus({ days: 2 }).toRelative() //=> "2 days ago"
  6582. * @example DateTime.now().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"
  6583. * @example DateTime.now().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"
  6584. */
  6585. ;
  6586. _proto.toRelative = function toRelative(options) {
  6587. if (options === void 0) {
  6588. options = {};
  6589. }
  6590. if (!this.isValid) return null;
  6591. var base = options.base || DateTime.fromObject({
  6592. zone: this.zone
  6593. }),
  6594. padding = options.padding ? this < base ? -options.padding : options.padding : 0;
  6595. var units = ["years", "months", "days", "hours", "minutes", "seconds"];
  6596. var unit = options.unit;
  6597. if (Array.isArray(options.unit)) {
  6598. units = options.unit;
  6599. unit = undefined;
  6600. }
  6601. return diffRelative(base, this.plus(padding), Object.assign(options, {
  6602. numeric: "always",
  6603. units: units,
  6604. unit: unit
  6605. }));
  6606. }
  6607. /**
  6608. * Returns a string representation of this date relative to today, such as "yesterday" or "next month".
  6609. * Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
  6610. * @param {Object} options - options that affect the output
  6611. * @param {DateTime} [options.base=DateTime.now()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
  6612. * @param {string} options.locale - override the locale of this DateTime
  6613. * @param {string} options.unit - use a specific unit; if omitted, the method will pick the unit. Use one of "years", "quarters", "months", "weeks", or "days"
  6614. * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
  6615. * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"
  6616. * @example DateTime.now().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana"
  6617. * @example DateTime.now().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"
  6618. * @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
  6619. */
  6620. ;
  6621. _proto.toRelativeCalendar = function toRelativeCalendar(options) {
  6622. if (options === void 0) {
  6623. options = {};
  6624. }
  6625. if (!this.isValid) return null;
  6626. return diffRelative(options.base || DateTime.fromObject({
  6627. zone: this.zone
  6628. }), this, Object.assign(options, {
  6629. numeric: "auto",
  6630. units: ["years", "months", "days"],
  6631. calendary: true
  6632. }));
  6633. }
  6634. /**
  6635. * Return the min of several date times
  6636. * @param {...DateTime} dateTimes - the DateTimes from which to choose the minimum
  6637. * @return {DateTime} the min DateTime, or undefined if called with no argument
  6638. */
  6639. ;
  6640. DateTime.min = function min() {
  6641. for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
  6642. dateTimes[_key] = arguments[_key];
  6643. }
  6644. if (!dateTimes.every(DateTime.isDateTime)) {
  6645. throw new InvalidArgumentError("min requires all arguments be DateTimes");
  6646. }
  6647. return bestBy(dateTimes, function (i) {
  6648. return i.valueOf();
  6649. }, Math.min);
  6650. }
  6651. /**
  6652. * Return the max of several date times
  6653. * @param {...DateTime} dateTimes - the DateTimes from which to choose the maximum
  6654. * @return {DateTime} the max DateTime, or undefined if called with no argument
  6655. */
  6656. ;
  6657. DateTime.max = function max() {
  6658. for (var _len2 = arguments.length, dateTimes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6659. dateTimes[_key2] = arguments[_key2];
  6660. }
  6661. if (!dateTimes.every(DateTime.isDateTime)) {
  6662. throw new InvalidArgumentError("max requires all arguments be DateTimes");
  6663. }
  6664. return bestBy(dateTimes, function (i) {
  6665. return i.valueOf();
  6666. }, Math.max);
  6667. } // MISC
  6668. /**
  6669. * Explain how a string would be parsed by fromFormat()
  6670. * @param {string} text - the string to parse
  6671. * @param {string} fmt - the format the string is expected to be in (see description)
  6672. * @param {Object} options - options taken by fromFormat()
  6673. * @return {Object}
  6674. */
  6675. ;
  6676. DateTime.fromFormatExplain = function fromFormatExplain(text, fmt, options) {
  6677. if (options === void 0) {
  6678. options = {};
  6679. }
  6680. var _options = options,
  6681. _options$locale = _options.locale,
  6682. locale = _options$locale === void 0 ? null : _options$locale,
  6683. _options$numberingSys = _options.numberingSystem,
  6684. numberingSystem = _options$numberingSys === void 0 ? null : _options$numberingSys,
  6685. localeToUse = Locale.fromOpts({
  6686. locale: locale,
  6687. numberingSystem: numberingSystem,
  6688. defaultToEN: true
  6689. });
  6690. return explainFromTokens(localeToUse, text, fmt);
  6691. }
  6692. /**
  6693. * @deprecated use fromFormatExplain instead
  6694. */
  6695. ;
  6696. DateTime.fromStringExplain = function fromStringExplain(text, fmt, options) {
  6697. if (options === void 0) {
  6698. options = {};
  6699. }
  6700. return DateTime.fromFormatExplain(text, fmt, options);
  6701. } // FORMAT PRESETS
  6702. /**
  6703. * {@link toLocaleString} format like 10/14/1983
  6704. * @type {Object}
  6705. */
  6706. ;
  6707. _createClass(DateTime, [{
  6708. key: "isValid",
  6709. get: function get() {
  6710. return this.invalid === null;
  6711. }
  6712. /**
  6713. * Returns an error code if this DateTime is invalid, or null if the DateTime is valid
  6714. * @type {string}
  6715. */
  6716. }, {
  6717. key: "invalidReason",
  6718. get: function get() {
  6719. return this.invalid ? this.invalid.reason : null;
  6720. }
  6721. /**
  6722. * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid
  6723. * @type {string}
  6724. */
  6725. }, {
  6726. key: "invalidExplanation",
  6727. get: function get() {
  6728. return this.invalid ? this.invalid.explanation : null;
  6729. }
  6730. /**
  6731. * Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
  6732. *
  6733. * @type {string}
  6734. */
  6735. }, {
  6736. key: "locale",
  6737. get: function get() {
  6738. return this.isValid ? this.loc.locale : null;
  6739. }
  6740. /**
  6741. * Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
  6742. *
  6743. * @type {string}
  6744. */
  6745. }, {
  6746. key: "numberingSystem",
  6747. get: function get() {
  6748. return this.isValid ? this.loc.numberingSystem : null;
  6749. }
  6750. /**
  6751. * Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
  6752. *
  6753. * @type {string}
  6754. */
  6755. }, {
  6756. key: "outputCalendar",
  6757. get: function get() {
  6758. return this.isValid ? this.loc.outputCalendar : null;
  6759. }
  6760. /**
  6761. * Get the time zone associated with this DateTime.
  6762. * @type {Zone}
  6763. */
  6764. }, {
  6765. key: "zone",
  6766. get: function get() {
  6767. return this._zone;
  6768. }
  6769. /**
  6770. * Get the name of the time zone.
  6771. * @type {string}
  6772. */
  6773. }, {
  6774. key: "zoneName",
  6775. get: function get() {
  6776. return this.isValid ? this.zone.name : null;
  6777. }
  6778. /**
  6779. * Get the year
  6780. * @example DateTime.local(2017, 5, 25).year //=> 2017
  6781. * @type {number}
  6782. */
  6783. }, {
  6784. key: "year",
  6785. get: function get() {
  6786. return this.isValid ? this.c.year : NaN;
  6787. }
  6788. /**
  6789. * Get the quarter
  6790. * @example DateTime.local(2017, 5, 25).quarter //=> 2
  6791. * @type {number}
  6792. */
  6793. }, {
  6794. key: "quarter",
  6795. get: function get() {
  6796. return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
  6797. }
  6798. /**
  6799. * Get the month (1-12).
  6800. * @example DateTime.local(2017, 5, 25).month //=> 5
  6801. * @type {number}
  6802. */
  6803. }, {
  6804. key: "month",
  6805. get: function get() {
  6806. return this.isValid ? this.c.month : NaN;
  6807. }
  6808. /**
  6809. * Get the day of the month (1-30ish).
  6810. * @example DateTime.local(2017, 5, 25).day //=> 25
  6811. * @type {number}
  6812. */
  6813. }, {
  6814. key: "day",
  6815. get: function get() {
  6816. return this.isValid ? this.c.day : NaN;
  6817. }
  6818. /**
  6819. * Get the hour of the day (0-23).
  6820. * @example DateTime.local(2017, 5, 25, 9).hour //=> 9
  6821. * @type {number}
  6822. */
  6823. }, {
  6824. key: "hour",
  6825. get: function get() {
  6826. return this.isValid ? this.c.hour : NaN;
  6827. }
  6828. /**
  6829. * Get the minute of the hour (0-59).
  6830. * @example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
  6831. * @type {number}
  6832. */
  6833. }, {
  6834. key: "minute",
  6835. get: function get() {
  6836. return this.isValid ? this.c.minute : NaN;
  6837. }
  6838. /**
  6839. * Get the second of the minute (0-59).
  6840. * @example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
  6841. * @type {number}
  6842. */
  6843. }, {
  6844. key: "second",
  6845. get: function get() {
  6846. return this.isValid ? this.c.second : NaN;
  6847. }
  6848. /**
  6849. * Get the millisecond of the second (0-999).
  6850. * @example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
  6851. * @type {number}
  6852. */
  6853. }, {
  6854. key: "millisecond",
  6855. get: function get() {
  6856. return this.isValid ? this.c.millisecond : NaN;
  6857. }
  6858. /**
  6859. * Get the week year
  6860. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6861. * @example DateTime.local(2014, 12, 31).weekYear //=> 2015
  6862. * @type {number}
  6863. */
  6864. }, {
  6865. key: "weekYear",
  6866. get: function get() {
  6867. return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
  6868. }
  6869. /**
  6870. * Get the week number of the week year (1-52ish).
  6871. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6872. * @example DateTime.local(2017, 5, 25).weekNumber //=> 21
  6873. * @type {number}
  6874. */
  6875. }, {
  6876. key: "weekNumber",
  6877. get: function get() {
  6878. return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
  6879. }
  6880. /**
  6881. * Get the day of the week.
  6882. * 1 is Monday and 7 is Sunday
  6883. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6884. * @example DateTime.local(2014, 11, 31).weekday //=> 4
  6885. * @type {number}
  6886. */
  6887. }, {
  6888. key: "weekday",
  6889. get: function get() {
  6890. return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
  6891. }
  6892. /**
  6893. * Get the ordinal (meaning the day of the year)
  6894. * @example DateTime.local(2017, 5, 25).ordinal //=> 145
  6895. * @type {number|DateTime}
  6896. */
  6897. }, {
  6898. key: "ordinal",
  6899. get: function get() {
  6900. return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
  6901. }
  6902. /**
  6903. * Get the human readable short month name, such as 'Oct'.
  6904. * Defaults to the system's locale if no locale has been specified
  6905. * @example DateTime.local(2017, 10, 30).monthShort //=> Oct
  6906. * @type {string}
  6907. */
  6908. }, {
  6909. key: "monthShort",
  6910. get: function get() {
  6911. return this.isValid ? Info.months("short", {
  6912. locObj: this.loc
  6913. })[this.month - 1] : null;
  6914. }
  6915. /**
  6916. * Get the human readable long month name, such as 'October'.
  6917. * Defaults to the system's locale if no locale has been specified
  6918. * @example DateTime.local(2017, 10, 30).monthLong //=> October
  6919. * @type {string}
  6920. */
  6921. }, {
  6922. key: "monthLong",
  6923. get: function get() {
  6924. return this.isValid ? Info.months("long", {
  6925. locObj: this.loc
  6926. })[this.month - 1] : null;
  6927. }
  6928. /**
  6929. * Get the human readable short weekday, such as 'Mon'.
  6930. * Defaults to the system's locale if no locale has been specified
  6931. * @example DateTime.local(2017, 10, 30).weekdayShort //=> Mon
  6932. * @type {string}
  6933. */
  6934. }, {
  6935. key: "weekdayShort",
  6936. get: function get() {
  6937. return this.isValid ? Info.weekdays("short", {
  6938. locObj: this.loc
  6939. })[this.weekday - 1] : null;
  6940. }
  6941. /**
  6942. * Get the human readable long weekday, such as 'Monday'.
  6943. * Defaults to the system's locale if no locale has been specified
  6944. * @example DateTime.local(2017, 10, 30).weekdayLong //=> Monday
  6945. * @type {string}
  6946. */
  6947. }, {
  6948. key: "weekdayLong",
  6949. get: function get() {
  6950. return this.isValid ? Info.weekdays("long", {
  6951. locObj: this.loc
  6952. })[this.weekday - 1] : null;
  6953. }
  6954. /**
  6955. * Get the UTC offset of this DateTime in minutes
  6956. * @example DateTime.now().offset //=> -240
  6957. * @example DateTime.utc().offset //=> 0
  6958. * @type {number}
  6959. */
  6960. }, {
  6961. key: "offset",
  6962. get: function get() {
  6963. return this.isValid ? +this.o : NaN;
  6964. }
  6965. /**
  6966. * Get the short human name for the zone's current offset, for example "EST" or "EDT".
  6967. * Defaults to the system's locale if no locale has been specified
  6968. * @type {string}
  6969. */
  6970. }, {
  6971. key: "offsetNameShort",
  6972. get: function get() {
  6973. if (this.isValid) {
  6974. return this.zone.offsetName(this.ts, {
  6975. format: "short",
  6976. locale: this.locale
  6977. });
  6978. } else {
  6979. return null;
  6980. }
  6981. }
  6982. /**
  6983. * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time".
  6984. * Defaults to the system's locale if no locale has been specified
  6985. * @type {string}
  6986. */
  6987. }, {
  6988. key: "offsetNameLong",
  6989. get: function get() {
  6990. if (this.isValid) {
  6991. return this.zone.offsetName(this.ts, {
  6992. format: "long",
  6993. locale: this.locale
  6994. });
  6995. } else {
  6996. return null;
  6997. }
  6998. }
  6999. /**
  7000. * Get whether this zone's offset ever changes, as in a DST.
  7001. * @type {boolean}
  7002. */
  7003. }, {
  7004. key: "isOffsetFixed",
  7005. get: function get() {
  7006. return this.isValid ? this.zone.universal : null;
  7007. }
  7008. /**
  7009. * Get whether the DateTime is in a DST.
  7010. * @type {boolean}
  7011. */
  7012. }, {
  7013. key: "isInDST",
  7014. get: function get() {
  7015. if (this.isOffsetFixed) {
  7016. return false;
  7017. } else {
  7018. return this.offset > this.set({
  7019. month: 1
  7020. }).offset || this.offset > this.set({
  7021. month: 5
  7022. }).offset;
  7023. }
  7024. }
  7025. /**
  7026. * Returns true if this DateTime is in a leap year, false otherwise
  7027. * @example DateTime.local(2016).isInLeapYear //=> true
  7028. * @example DateTime.local(2013).isInLeapYear //=> false
  7029. * @type {boolean}
  7030. */
  7031. }, {
  7032. key: "isInLeapYear",
  7033. get: function get() {
  7034. return isLeapYear(this.year);
  7035. }
  7036. /**
  7037. * Returns the number of days in this DateTime's month
  7038. * @example DateTime.local(2016, 2).daysInMonth //=> 29
  7039. * @example DateTime.local(2016, 3).daysInMonth //=> 31
  7040. * @type {number}
  7041. */
  7042. }, {
  7043. key: "daysInMonth",
  7044. get: function get() {
  7045. return daysInMonth(this.year, this.month);
  7046. }
  7047. /**
  7048. * Returns the number of days in this DateTime's year
  7049. * @example DateTime.local(2016).daysInYear //=> 366
  7050. * @example DateTime.local(2013).daysInYear //=> 365
  7051. * @type {number}
  7052. */
  7053. }, {
  7054. key: "daysInYear",
  7055. get: function get() {
  7056. return this.isValid ? daysInYear(this.year) : NaN;
  7057. }
  7058. /**
  7059. * Returns the number of weeks in this DateTime's year
  7060. * @see https://en.wikipedia.org/wiki/ISO_week_date
  7061. * @example DateTime.local(2004).weeksInWeekYear //=> 53
  7062. * @example DateTime.local(2013).weeksInWeekYear //=> 52
  7063. * @type {number}
  7064. */
  7065. }, {
  7066. key: "weeksInWeekYear",
  7067. get: function get() {
  7068. return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
  7069. }
  7070. }], [{
  7071. key: "DATE_SHORT",
  7072. get: function get() {
  7073. return DATE_SHORT;
  7074. }
  7075. /**
  7076. * {@link toLocaleString} format like 'Oct 14, 1983'
  7077. * @type {Object}
  7078. */
  7079. }, {
  7080. key: "DATE_MED",
  7081. get: function get() {
  7082. return DATE_MED;
  7083. }
  7084. /**
  7085. * {@link toLocaleString} format like 'Fri, Oct 14, 1983'
  7086. * @type {Object}
  7087. */
  7088. }, {
  7089. key: "DATE_MED_WITH_WEEKDAY",
  7090. get: function get() {
  7091. return DATE_MED_WITH_WEEKDAY;
  7092. }
  7093. /**
  7094. * {@link toLocaleString} format like 'October 14, 1983'
  7095. * @type {Object}
  7096. */
  7097. }, {
  7098. key: "DATE_FULL",
  7099. get: function get() {
  7100. return DATE_FULL;
  7101. }
  7102. /**
  7103. * {@link toLocaleString} format like 'Tuesday, October 14, 1983'
  7104. * @type {Object}
  7105. */
  7106. }, {
  7107. key: "DATE_HUGE",
  7108. get: function get() {
  7109. return DATE_HUGE;
  7110. }
  7111. /**
  7112. * {@link toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
  7113. * @type {Object}
  7114. */
  7115. }, {
  7116. key: "TIME_SIMPLE",
  7117. get: function get() {
  7118. return TIME_SIMPLE;
  7119. }
  7120. /**
  7121. * {@link toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
  7122. * @type {Object}
  7123. */
  7124. }, {
  7125. key: "TIME_WITH_SECONDS",
  7126. get: function get() {
  7127. return TIME_WITH_SECONDS;
  7128. }
  7129. /**
  7130. * {@link toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
  7131. * @type {Object}
  7132. */
  7133. }, {
  7134. key: "TIME_WITH_SHORT_OFFSET",
  7135. get: function get() {
  7136. return TIME_WITH_SHORT_OFFSET;
  7137. }
  7138. /**
  7139. * {@link toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7140. * @type {Object}
  7141. */
  7142. }, {
  7143. key: "TIME_WITH_LONG_OFFSET",
  7144. get: function get() {
  7145. return TIME_WITH_LONG_OFFSET;
  7146. }
  7147. /**
  7148. * {@link toLocaleString} format like '09:30', always 24-hour.
  7149. * @type {Object}
  7150. */
  7151. }, {
  7152. key: "TIME_24_SIMPLE",
  7153. get: function get() {
  7154. return TIME_24_SIMPLE;
  7155. }
  7156. /**
  7157. * {@link toLocaleString} format like '09:30:23', always 24-hour.
  7158. * @type {Object}
  7159. */
  7160. }, {
  7161. key: "TIME_24_WITH_SECONDS",
  7162. get: function get() {
  7163. return TIME_24_WITH_SECONDS;
  7164. }
  7165. /**
  7166. * {@link toLocaleString} format like '09:30:23 EDT', always 24-hour.
  7167. * @type {Object}
  7168. */
  7169. }, {
  7170. key: "TIME_24_WITH_SHORT_OFFSET",
  7171. get: function get() {
  7172. return TIME_24_WITH_SHORT_OFFSET;
  7173. }
  7174. /**
  7175. * {@link toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
  7176. * @type {Object}
  7177. */
  7178. }, {
  7179. key: "TIME_24_WITH_LONG_OFFSET",
  7180. get: function get() {
  7181. return TIME_24_WITH_LONG_OFFSET;
  7182. }
  7183. /**
  7184. * {@link toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
  7185. * @type {Object}
  7186. */
  7187. }, {
  7188. key: "DATETIME_SHORT",
  7189. get: function get() {
  7190. return DATETIME_SHORT;
  7191. }
  7192. /**
  7193. * {@link toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
  7194. * @type {Object}
  7195. */
  7196. }, {
  7197. key: "DATETIME_SHORT_WITH_SECONDS",
  7198. get: function get() {
  7199. return DATETIME_SHORT_WITH_SECONDS;
  7200. }
  7201. /**
  7202. * {@link toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
  7203. * @type {Object}
  7204. */
  7205. }, {
  7206. key: "DATETIME_MED",
  7207. get: function get() {
  7208. return DATETIME_MED;
  7209. }
  7210. /**
  7211. * {@link toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
  7212. * @type {Object}
  7213. */
  7214. }, {
  7215. key: "DATETIME_MED_WITH_SECONDS",
  7216. get: function get() {
  7217. return DATETIME_MED_WITH_SECONDS;
  7218. }
  7219. /**
  7220. * {@link toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
  7221. * @type {Object}
  7222. */
  7223. }, {
  7224. key: "DATETIME_MED_WITH_WEEKDAY",
  7225. get: function get() {
  7226. return DATETIME_MED_WITH_WEEKDAY;
  7227. }
  7228. /**
  7229. * {@link toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
  7230. * @type {Object}
  7231. */
  7232. }, {
  7233. key: "DATETIME_FULL",
  7234. get: function get() {
  7235. return DATETIME_FULL;
  7236. }
  7237. /**
  7238. * {@link toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
  7239. * @type {Object}
  7240. */
  7241. }, {
  7242. key: "DATETIME_FULL_WITH_SECONDS",
  7243. get: function get() {
  7244. return DATETIME_FULL_WITH_SECONDS;
  7245. }
  7246. /**
  7247. * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7248. * @type {Object}
  7249. */
  7250. }, {
  7251. key: "DATETIME_HUGE",
  7252. get: function get() {
  7253. return DATETIME_HUGE;
  7254. }
  7255. /**
  7256. * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7257. * @type {Object}
  7258. */
  7259. }, {
  7260. key: "DATETIME_HUGE_WITH_SECONDS",
  7261. get: function get() {
  7262. return DATETIME_HUGE_WITH_SECONDS;
  7263. }
  7264. }]);
  7265. return DateTime;
  7266. }();
  7267. function friendlyDateTime(dateTimeish) {
  7268. if (DateTime.isDateTime(dateTimeish)) {
  7269. return dateTimeish;
  7270. } else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) {
  7271. return DateTime.fromJSDate(dateTimeish);
  7272. } else if (dateTimeish && typeof dateTimeish === "object") {
  7273. return DateTime.fromObject(dateTimeish);
  7274. } else {
  7275. throw new InvalidArgumentError("Unknown datetime argument: " + dateTimeish + ", of type " + typeof dateTimeish);
  7276. }
  7277. }
  7278. var VERSION = "1.27.0";
  7279. exports.DateTime = DateTime;
  7280. exports.Duration = Duration;
  7281. exports.FixedOffsetZone = FixedOffsetZone;
  7282. exports.IANAZone = IANAZone;
  7283. exports.Info = Info;
  7284. exports.Interval = Interval;
  7285. exports.InvalidZone = InvalidZone;
  7286. exports.LocalZone = LocalZone;
  7287. exports.Settings = Settings;
  7288. exports.VERSION = VERSION;
  7289. exports.Zone = Zone;
  7290. //# sourceMappingURL=luxon.js.map