luxon.js 252 KB

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