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 261KB

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