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

rrule-tz.js 361KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["rrule"] = factory();
  8. else
  9. root["rrule"] = factory();
  10. })(typeof self !== 'undefined' ? self : this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = 1);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ([
  98. /* 0 */
  99. /***/ (function(module, exports, __webpack_require__) {
  100. "use strict";
  101. Object.defineProperty(exports, '__esModule', { value: true });
  102. function _defineProperties(target, props) {
  103. for (var i = 0; i < props.length; i++) {
  104. var descriptor = props[i];
  105. descriptor.enumerable = descriptor.enumerable || false;
  106. descriptor.configurable = true;
  107. if ("value" in descriptor) descriptor.writable = true;
  108. Object.defineProperty(target, descriptor.key, descriptor);
  109. }
  110. }
  111. function _createClass(Constructor, protoProps, staticProps) {
  112. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  113. if (staticProps) _defineProperties(Constructor, staticProps);
  114. return Constructor;
  115. }
  116. function _inheritsLoose(subClass, superClass) {
  117. subClass.prototype = Object.create(superClass.prototype);
  118. subClass.prototype.constructor = subClass;
  119. subClass.__proto__ = superClass;
  120. }
  121. function _getPrototypeOf(o) {
  122. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  123. return o.__proto__ || Object.getPrototypeOf(o);
  124. };
  125. return _getPrototypeOf(o);
  126. }
  127. function _setPrototypeOf(o, p) {
  128. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  129. o.__proto__ = p;
  130. return o;
  131. };
  132. return _setPrototypeOf(o, p);
  133. }
  134. function isNativeReflectConstruct() {
  135. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  136. if (Reflect.construct.sham) return false;
  137. if (typeof Proxy === "function") return true;
  138. try {
  139. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  140. return true;
  141. } catch (e) {
  142. return false;
  143. }
  144. }
  145. function _construct(Parent, args, Class) {
  146. if (isNativeReflectConstruct()) {
  147. _construct = Reflect.construct;
  148. } else {
  149. _construct = function _construct(Parent, args, Class) {
  150. var a = [null];
  151. a.push.apply(a, args);
  152. var Constructor = Function.bind.apply(Parent, a);
  153. var instance = new Constructor();
  154. if (Class) _setPrototypeOf(instance, Class.prototype);
  155. return instance;
  156. };
  157. }
  158. return _construct.apply(null, arguments);
  159. }
  160. function _isNativeFunction(fn) {
  161. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  162. }
  163. function _wrapNativeSuper(Class) {
  164. var _cache = typeof Map === "function" ? new Map() : undefined;
  165. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  166. if (Class === null || !_isNativeFunction(Class)) return Class;
  167. if (typeof Class !== "function") {
  168. throw new TypeError("Super expression must either be null or a function");
  169. }
  170. if (typeof _cache !== "undefined") {
  171. if (_cache.has(Class)) return _cache.get(Class);
  172. _cache.set(Class, Wrapper);
  173. }
  174. function Wrapper() {
  175. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  176. }
  177. Wrapper.prototype = Object.create(Class.prototype, {
  178. constructor: {
  179. value: Wrapper,
  180. enumerable: false,
  181. writable: true,
  182. configurable: true
  183. }
  184. });
  185. return _setPrototypeOf(Wrapper, Class);
  186. };
  187. return _wrapNativeSuper(Class);
  188. }
  189. // these aren't really private, but nor are they really useful to document
  190. /**
  191. * @private
  192. */
  193. var LuxonError =
  194. /*#__PURE__*/
  195. function (_Error) {
  196. _inheritsLoose(LuxonError, _Error);
  197. function LuxonError() {
  198. return _Error.apply(this, arguments) || this;
  199. }
  200. return LuxonError;
  201. }(_wrapNativeSuper(Error));
  202. /**
  203. * @private
  204. */
  205. var InvalidDateTimeError =
  206. /*#__PURE__*/
  207. function (_LuxonError) {
  208. _inheritsLoose(InvalidDateTimeError, _LuxonError);
  209. function InvalidDateTimeError(reason) {
  210. return _LuxonError.call(this, "Invalid DateTime: " + reason.toMessage()) || this;
  211. }
  212. return InvalidDateTimeError;
  213. }(LuxonError);
  214. /**
  215. * @private
  216. */
  217. var InvalidIntervalError =
  218. /*#__PURE__*/
  219. function (_LuxonError2) {
  220. _inheritsLoose(InvalidIntervalError, _LuxonError2);
  221. function InvalidIntervalError(reason) {
  222. return _LuxonError2.call(this, "Invalid Interval: " + reason.toMessage()) || this;
  223. }
  224. return InvalidIntervalError;
  225. }(LuxonError);
  226. /**
  227. * @private
  228. */
  229. var InvalidDurationError =
  230. /*#__PURE__*/
  231. function (_LuxonError3) {
  232. _inheritsLoose(InvalidDurationError, _LuxonError3);
  233. function InvalidDurationError(reason) {
  234. return _LuxonError3.call(this, "Invalid Duration: " + reason.toMessage()) || this;
  235. }
  236. return InvalidDurationError;
  237. }(LuxonError);
  238. /**
  239. * @private
  240. */
  241. var ConflictingSpecificationError =
  242. /*#__PURE__*/
  243. function (_LuxonError4) {
  244. _inheritsLoose(ConflictingSpecificationError, _LuxonError4);
  245. function ConflictingSpecificationError() {
  246. return _LuxonError4.apply(this, arguments) || this;
  247. }
  248. return ConflictingSpecificationError;
  249. }(LuxonError);
  250. /**
  251. * @private
  252. */
  253. var InvalidUnitError =
  254. /*#__PURE__*/
  255. function (_LuxonError5) {
  256. _inheritsLoose(InvalidUnitError, _LuxonError5);
  257. function InvalidUnitError(unit) {
  258. return _LuxonError5.call(this, "Invalid unit " + unit) || this;
  259. }
  260. return InvalidUnitError;
  261. }(LuxonError);
  262. /**
  263. * @private
  264. */
  265. var InvalidArgumentError =
  266. /*#__PURE__*/
  267. function (_LuxonError6) {
  268. _inheritsLoose(InvalidArgumentError, _LuxonError6);
  269. function InvalidArgumentError() {
  270. return _LuxonError6.apply(this, arguments) || this;
  271. }
  272. return InvalidArgumentError;
  273. }(LuxonError);
  274. /**
  275. * @private
  276. */
  277. var ZoneIsAbstractError =
  278. /*#__PURE__*/
  279. function (_LuxonError7) {
  280. _inheritsLoose(ZoneIsAbstractError, _LuxonError7);
  281. function ZoneIsAbstractError() {
  282. return _LuxonError7.call(this, "Zone is an abstract class") || this;
  283. }
  284. return ZoneIsAbstractError;
  285. }(LuxonError);
  286. /**
  287. * @private
  288. */
  289. var n = "numeric",
  290. s = "short",
  291. l = "long";
  292. var DATE_SHORT = {
  293. year: n,
  294. month: n,
  295. day: n
  296. };
  297. var DATE_MED = {
  298. year: n,
  299. month: s,
  300. day: n
  301. };
  302. var DATE_FULL = {
  303. year: n,
  304. month: l,
  305. day: n
  306. };
  307. var DATE_HUGE = {
  308. year: n,
  309. month: l,
  310. day: n,
  311. weekday: l
  312. };
  313. var TIME_SIMPLE = {
  314. hour: n,
  315. minute: n
  316. };
  317. var TIME_WITH_SECONDS = {
  318. hour: n,
  319. minute: n,
  320. second: n
  321. };
  322. var TIME_WITH_SHORT_OFFSET = {
  323. hour: n,
  324. minute: n,
  325. second: n,
  326. timeZoneName: s
  327. };
  328. var TIME_WITH_LONG_OFFSET = {
  329. hour: n,
  330. minute: n,
  331. second: n,
  332. timeZoneName: l
  333. };
  334. var TIME_24_SIMPLE = {
  335. hour: n,
  336. minute: n,
  337. hour12: false
  338. };
  339. /**
  340. * {@link toLocaleString}; format like '09:30:23', always 24-hour.
  341. */
  342. var TIME_24_WITH_SECONDS = {
  343. hour: n,
  344. minute: n,
  345. second: n,
  346. hour12: false
  347. };
  348. /**
  349. * {@link toLocaleString}; format like '09:30:23 EDT', always 24-hour.
  350. */
  351. var TIME_24_WITH_SHORT_OFFSET = {
  352. hour: n,
  353. minute: n,
  354. second: n,
  355. hour12: false,
  356. timeZoneName: s
  357. };
  358. /**
  359. * {@link toLocaleString}; format like '09:30:23 Eastern Daylight Time', always 24-hour.
  360. */
  361. var TIME_24_WITH_LONG_OFFSET = {
  362. hour: n,
  363. minute: n,
  364. second: n,
  365. hour12: false,
  366. timeZoneName: l
  367. };
  368. /**
  369. * {@link toLocaleString}; format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
  370. */
  371. var DATETIME_SHORT = {
  372. year: n,
  373. month: n,
  374. day: n,
  375. hour: n,
  376. minute: n
  377. };
  378. /**
  379. * {@link toLocaleString}; format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
  380. */
  381. var DATETIME_SHORT_WITH_SECONDS = {
  382. year: n,
  383. month: n,
  384. day: n,
  385. hour: n,
  386. minute: n,
  387. second: n
  388. };
  389. var DATETIME_MED = {
  390. year: n,
  391. month: s,
  392. day: n,
  393. hour: n,
  394. minute: n
  395. };
  396. var DATETIME_MED_WITH_SECONDS = {
  397. year: n,
  398. month: s,
  399. day: n,
  400. hour: n,
  401. minute: n,
  402. second: n
  403. };
  404. var DATETIME_MED_WITH_WEEKDAY = {
  405. year: n,
  406. month: s,
  407. day: n,
  408. weekday: s,
  409. hour: n,
  410. minute: n
  411. };
  412. var DATETIME_FULL = {
  413. year: n,
  414. month: l,
  415. day: n,
  416. hour: n,
  417. minute: n,
  418. timeZoneName: s
  419. };
  420. var DATETIME_FULL_WITH_SECONDS = {
  421. year: n,
  422. month: l,
  423. day: n,
  424. hour: n,
  425. minute: n,
  426. second: n,
  427. timeZoneName: s
  428. };
  429. var DATETIME_HUGE = {
  430. year: n,
  431. month: l,
  432. day: n,
  433. weekday: l,
  434. hour: n,
  435. minute: n,
  436. timeZoneName: l
  437. };
  438. var DATETIME_HUGE_WITH_SECONDS = {
  439. year: n,
  440. month: l,
  441. day: n,
  442. weekday: l,
  443. hour: n,
  444. minute: n,
  445. second: n,
  446. timeZoneName: l
  447. };
  448. /*
  449. This is just a junk drawer, containing anything used across multiple classes.
  450. Because Luxon is small(ish), this should stay small and we won't worry about splitting
  451. it up into, say, parsingUtil.js and basicUtil.js and so on. But they are divided up by feature area.
  452. */
  453. /**
  454. * @private
  455. */
  456. // TYPES
  457. function isUndefined(o) {
  458. return typeof o === "undefined";
  459. }
  460. function isNumber(o) {
  461. return typeof o === "number";
  462. }
  463. function isInteger(o) {
  464. return typeof o === "number" && o % 1 === 0;
  465. }
  466. function isString(o) {
  467. return typeof o === "string";
  468. }
  469. function isDate(o) {
  470. return Object.prototype.toString.call(o) === "[object Date]";
  471. } // CAPABILITIES
  472. function hasIntl() {
  473. try {
  474. return typeof Intl !== "undefined" && Intl.DateTimeFormat;
  475. } catch (e) {
  476. return false;
  477. }
  478. }
  479. function hasFormatToParts() {
  480. return !isUndefined(Intl.DateTimeFormat.prototype.formatToParts);
  481. }
  482. function hasRelative() {
  483. try {
  484. return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
  485. } catch (e) {
  486. return false;
  487. }
  488. } // OBJECTS AND ARRAYS
  489. function maybeArray(thing) {
  490. return Array.isArray(thing) ? thing : [thing];
  491. }
  492. function bestBy(arr, by, compare) {
  493. if (arr.length === 0) {
  494. return undefined;
  495. }
  496. return arr.reduce(function (best, next) {
  497. var pair = [by(next), next];
  498. if (!best) {
  499. return pair;
  500. } else if (compare(best[0], pair[0]) === best[0]) {
  501. return best;
  502. } else {
  503. return pair;
  504. }
  505. }, null)[1];
  506. }
  507. function pick(obj, keys) {
  508. return keys.reduce(function (a, k) {
  509. a[k] = obj[k];
  510. return a;
  511. }, {});
  512. }
  513. function hasOwnProperty(obj, prop) {
  514. return Object.prototype.hasOwnProperty.call(obj, prop);
  515. } // NUMBERS AND STRINGS
  516. function integerBetween(thing, bottom, top) {
  517. return isInteger(thing) && thing >= bottom && thing <= top;
  518. } // x % n but takes the sign of n instead of x
  519. function floorMod(x, n) {
  520. return x - n * Math.floor(x / n);
  521. }
  522. function padStart(input, n) {
  523. if (n === void 0) {
  524. n = 2;
  525. }
  526. if (input.toString().length < n) {
  527. return ("0".repeat(n) + input).slice(-n);
  528. } else {
  529. return input.toString();
  530. }
  531. }
  532. function parseInteger(string) {
  533. if (isUndefined(string) || string === null || string === "") {
  534. return undefined;
  535. } else {
  536. return parseInt(string, 10);
  537. }
  538. }
  539. function parseMillis(fraction) {
  540. // Return undefined (instead of 0) in these cases, where fraction is not set
  541. if (isUndefined(fraction) || fraction === null || fraction === "") {
  542. return undefined;
  543. } else {
  544. var f = parseFloat("0." + fraction) * 1000;
  545. return Math.floor(f);
  546. }
  547. }
  548. function roundTo(number, digits, towardZero) {
  549. if (towardZero === void 0) {
  550. towardZero = false;
  551. }
  552. var factor = Math.pow(10, digits),
  553. rounder = towardZero ? Math.trunc : Math.round;
  554. return rounder(number * factor) / factor;
  555. } // DATE BASICS
  556. function isLeapYear(year) {
  557. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  558. }
  559. function daysInYear(year) {
  560. return isLeapYear(year) ? 366 : 365;
  561. }
  562. function daysInMonth(year, month) {
  563. var modMonth = floorMod(month - 1, 12) + 1,
  564. modYear = year + (month - modMonth) / 12;
  565. if (modMonth === 2) {
  566. return isLeapYear(modYear) ? 29 : 28;
  567. } else {
  568. return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
  569. }
  570. } // covert a calendar object to a local timestamp (epoch, but with the offset baked in)
  571. function objToLocalTS(obj) {
  572. 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
  573. if (obj.year < 100 && obj.year >= 0) {
  574. d = new Date(d);
  575. d.setUTCFullYear(d.getUTCFullYear() - 1900);
  576. }
  577. return +d;
  578. }
  579. function weeksInWeekYear(weekYear) {
  580. var p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7,
  581. last = weekYear - 1,
  582. p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
  583. return p1 === 4 || p2 === 3 ? 53 : 52;
  584. }
  585. function untruncateYear(year) {
  586. if (year > 99) {
  587. return year;
  588. } else return year > 60 ? 1900 + year : 2000 + year;
  589. } // PARSING
  590. function parseZoneInfo(ts, offsetFormat, locale, timeZone) {
  591. if (timeZone === void 0) {
  592. timeZone = null;
  593. }
  594. var date = new Date(ts),
  595. intlOpts = {
  596. hour12: false,
  597. year: "numeric",
  598. month: "2-digit",
  599. day: "2-digit",
  600. hour: "2-digit",
  601. minute: "2-digit"
  602. };
  603. if (timeZone) {
  604. intlOpts.timeZone = timeZone;
  605. }
  606. var modified = Object.assign({
  607. timeZoneName: offsetFormat
  608. }, intlOpts),
  609. intl = hasIntl();
  610. if (intl && hasFormatToParts()) {
  611. var parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find(function (m) {
  612. return m.type.toLowerCase() === "timezonename";
  613. });
  614. return parsed ? parsed.value : null;
  615. } else if (intl) {
  616. // this probably doesn't work for all locales
  617. var without = new Intl.DateTimeFormat(locale, intlOpts).format(date),
  618. included = new Intl.DateTimeFormat(locale, modified).format(date),
  619. diffed = included.substring(without.length),
  620. trimmed = diffed.replace(/^[, \u200e]+/, "");
  621. return trimmed;
  622. } else {
  623. return null;
  624. }
  625. } // signedOffset('-5', '30') -> -330
  626. function signedOffset(offHourStr, offMinuteStr) {
  627. var offHour = parseInt(offHourStr, 10); // don't || this because we want to preserve -0
  628. if (Number.isNaN(offHour)) {
  629. offHour = 0;
  630. }
  631. var offMin = parseInt(offMinuteStr, 10) || 0,
  632. offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
  633. return offHour * 60 + offMinSigned;
  634. } // COERCION
  635. function asNumber(value) {
  636. var numericValue = Number(value);
  637. if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue)) throw new InvalidArgumentError("Invalid unit value " + value);
  638. return numericValue;
  639. }
  640. function normalizeObject(obj, normalizer, nonUnitKeys) {
  641. var normalized = {};
  642. for (var u in obj) {
  643. if (hasOwnProperty(obj, u)) {
  644. if (nonUnitKeys.indexOf(u) >= 0) continue;
  645. var v = obj[u];
  646. if (v === undefined || v === null) continue;
  647. normalized[normalizer(u)] = asNumber(v);
  648. }
  649. }
  650. return normalized;
  651. }
  652. function formatOffset(offset, format) {
  653. var hours = Math.trunc(offset / 60),
  654. minutes = Math.abs(offset % 60),
  655. sign = hours >= 0 && !Object.is(hours, -0) ? "+" : "-",
  656. base = "" + sign + Math.abs(hours);
  657. switch (format) {
  658. case "short":
  659. return "" + sign + padStart(Math.abs(hours), 2) + ":" + padStart(minutes, 2);
  660. case "narrow":
  661. return minutes > 0 ? base + ":" + minutes : base;
  662. case "techie":
  663. return "" + sign + padStart(Math.abs(hours), 2) + padStart(minutes, 2);
  664. default:
  665. throw new RangeError("Value format " + format + " is out of range for property format");
  666. }
  667. }
  668. function timeObject(obj) {
  669. return pick(obj, ["hour", "minute", "second", "millisecond"]);
  670. }
  671. var ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z_+-]{1,256}(\/[A-Za-z_+-]{1,256})?)?/;
  672. function stringify(obj) {
  673. return JSON.stringify(obj, Object.keys(obj).sort());
  674. }
  675. /**
  676. * @private
  677. */
  678. var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  679. var monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  680. var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
  681. function months(length) {
  682. switch (length) {
  683. case "narrow":
  684. return monthsNarrow;
  685. case "short":
  686. return monthsShort;
  687. case "long":
  688. return monthsLong;
  689. case "numeric":
  690. return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
  691. case "2-digit":
  692. return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  693. default:
  694. return null;
  695. }
  696. }
  697. var weekdaysLong = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
  698. var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
  699. var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"];
  700. function weekdays(length) {
  701. switch (length) {
  702. case "narrow":
  703. return weekdaysNarrow;
  704. case "short":
  705. return weekdaysShort;
  706. case "long":
  707. return weekdaysLong;
  708. case "numeric":
  709. return ["1", "2", "3", "4", "5", "6", "7"];
  710. default:
  711. return null;
  712. }
  713. }
  714. var meridiems = ["AM", "PM"];
  715. var erasLong = ["Before Christ", "Anno Domini"];
  716. var erasShort = ["BC", "AD"];
  717. var erasNarrow = ["B", "A"];
  718. function eras(length) {
  719. switch (length) {
  720. case "narrow":
  721. return erasNarrow;
  722. case "short":
  723. return erasShort;
  724. case "long":
  725. return erasLong;
  726. default:
  727. return null;
  728. }
  729. }
  730. function meridiemForDateTime(dt) {
  731. return meridiems[dt.hour < 12 ? 0 : 1];
  732. }
  733. function weekdayForDateTime(dt, length) {
  734. return weekdays(length)[dt.weekday - 1];
  735. }
  736. function monthForDateTime(dt, length) {
  737. return months(length)[dt.month - 1];
  738. }
  739. function eraForDateTime(dt, length) {
  740. return eras(length)[dt.year < 0 ? 0 : 1];
  741. }
  742. function formatRelativeTime(unit, count, numeric, narrow) {
  743. if (numeric === void 0) {
  744. numeric = "always";
  745. }
  746. if (narrow === void 0) {
  747. narrow = false;
  748. }
  749. var units = {
  750. years: ["year", "yr."],
  751. quarters: ["quarter", "qtr."],
  752. months: ["month", "mo."],
  753. weeks: ["week", "wk."],
  754. days: ["day", "day", "days"],
  755. hours: ["hour", "hr."],
  756. minutes: ["minute", "min."],
  757. seconds: ["second", "sec."]
  758. };
  759. var lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
  760. if (numeric === "auto" && lastable) {
  761. var isDay = unit === "days";
  762. switch (count) {
  763. case 1:
  764. return isDay ? "tomorrow" : "next " + units[unit][0];
  765. case -1:
  766. return isDay ? "yesterday" : "last " + units[unit][0];
  767. case 0:
  768. return isDay ? "today" : "this " + units[unit][0];
  769. default: // fall through
  770. }
  771. }
  772. var isInPast = Object.is(count, -0) || count < 0,
  773. fmtValue = Math.abs(count),
  774. singular = fmtValue === 1,
  775. lilUnits = units[unit],
  776. fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit;
  777. return isInPast ? fmtValue + " " + fmtUnit + " ago" : "in " + fmtValue + " " + fmtUnit;
  778. }
  779. function formatString(knownFormat) {
  780. // these all have the offsets removed because we don't have access to them
  781. // without all the intl stuff this is backfilling
  782. var filtered = pick(knownFormat, ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName", "hour12"]),
  783. key = stringify(filtered),
  784. dateTimeHuge = "EEEE, LLLL d, yyyy, h:mm a";
  785. switch (key) {
  786. case stringify(DATE_SHORT):
  787. return "M/d/yyyy";
  788. case stringify(DATE_MED):
  789. return "LLL d, yyyy";
  790. case stringify(DATE_FULL):
  791. return "LLLL d, yyyy";
  792. case stringify(DATE_HUGE):
  793. return "EEEE, LLLL d, yyyy";
  794. case stringify(TIME_SIMPLE):
  795. return "h:mm a";
  796. case stringify(TIME_WITH_SECONDS):
  797. return "h:mm:ss a";
  798. case stringify(TIME_WITH_SHORT_OFFSET):
  799. return "h:mm a";
  800. case stringify(TIME_WITH_LONG_OFFSET):
  801. return "h:mm a";
  802. case stringify(TIME_24_SIMPLE):
  803. return "HH:mm";
  804. case stringify(TIME_24_WITH_SECONDS):
  805. return "HH:mm:ss";
  806. case stringify(TIME_24_WITH_SHORT_OFFSET):
  807. return "HH:mm";
  808. case stringify(TIME_24_WITH_LONG_OFFSET):
  809. return "HH:mm";
  810. case stringify(DATETIME_SHORT):
  811. return "M/d/yyyy, h:mm a";
  812. case stringify(DATETIME_MED):
  813. return "LLL d, yyyy, h:mm a";
  814. case stringify(DATETIME_FULL):
  815. return "LLLL d, yyyy, h:mm a";
  816. case stringify(DATETIME_HUGE):
  817. return dateTimeHuge;
  818. case stringify(DATETIME_SHORT_WITH_SECONDS):
  819. return "M/d/yyyy, h:mm:ss a";
  820. case stringify(DATETIME_MED_WITH_SECONDS):
  821. return "LLL d, yyyy, h:mm:ss a";
  822. case stringify(DATETIME_MED_WITH_WEEKDAY):
  823. return "EEE, d LLL yyyy, h:mm a";
  824. case stringify(DATETIME_FULL_WITH_SECONDS):
  825. return "LLLL d, yyyy, h:mm:ss a";
  826. case stringify(DATETIME_HUGE_WITH_SECONDS):
  827. return "EEEE, LLLL d, yyyy, h:mm:ss a";
  828. default:
  829. return dateTimeHuge;
  830. }
  831. }
  832. function stringifyTokens(splits, tokenToString) {
  833. var s = "";
  834. for (var _iterator = splits, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  835. var _ref;
  836. if (_isArray) {
  837. if (_i >= _iterator.length) break;
  838. _ref = _iterator[_i++];
  839. } else {
  840. _i = _iterator.next();
  841. if (_i.done) break;
  842. _ref = _i.value;
  843. }
  844. var token = _ref;
  845. if (token.literal) {
  846. s += token.val;
  847. } else {
  848. s += tokenToString(token.val);
  849. }
  850. }
  851. return s;
  852. }
  853. var _macroTokenToFormatOpts = {
  854. D: DATE_SHORT,
  855. DD: DATE_MED,
  856. DDD: DATE_FULL,
  857. DDDD: DATE_HUGE,
  858. t: TIME_SIMPLE,
  859. tt: TIME_WITH_SECONDS,
  860. ttt: TIME_WITH_SHORT_OFFSET,
  861. tttt: TIME_WITH_LONG_OFFSET,
  862. T: TIME_24_SIMPLE,
  863. TT: TIME_24_WITH_SECONDS,
  864. TTT: TIME_24_WITH_SHORT_OFFSET,
  865. TTTT: TIME_24_WITH_LONG_OFFSET,
  866. f: DATETIME_SHORT,
  867. ff: DATETIME_MED,
  868. fff: DATETIME_FULL,
  869. ffff: DATETIME_HUGE,
  870. F: DATETIME_SHORT_WITH_SECONDS,
  871. FF: DATETIME_MED_WITH_SECONDS,
  872. FFF: DATETIME_FULL_WITH_SECONDS,
  873. FFFF: DATETIME_HUGE_WITH_SECONDS
  874. };
  875. /**
  876. * @private
  877. */
  878. var Formatter =
  879. /*#__PURE__*/
  880. function () {
  881. Formatter.create = function create(locale, opts) {
  882. if (opts === void 0) {
  883. opts = {};
  884. }
  885. return new Formatter(locale, opts);
  886. };
  887. Formatter.parseFormat = function parseFormat(fmt) {
  888. var current = null,
  889. currentFull = "",
  890. bracketed = false;
  891. var splits = [];
  892. for (var i = 0; i < fmt.length; i++) {
  893. var c = fmt.charAt(i);
  894. if (c === "'") {
  895. if (currentFull.length > 0) {
  896. splits.push({
  897. literal: bracketed,
  898. val: currentFull
  899. });
  900. }
  901. current = null;
  902. currentFull = "";
  903. bracketed = !bracketed;
  904. } else if (bracketed) {
  905. currentFull += c;
  906. } else if (c === current) {
  907. currentFull += c;
  908. } else {
  909. if (currentFull.length > 0) {
  910. splits.push({
  911. literal: false,
  912. val: currentFull
  913. });
  914. }
  915. currentFull = c;
  916. current = c;
  917. }
  918. }
  919. if (currentFull.length > 0) {
  920. splits.push({
  921. literal: bracketed,
  922. val: currentFull
  923. });
  924. }
  925. return splits;
  926. };
  927. Formatter.macroTokenToFormatOpts = function macroTokenToFormatOpts(token) {
  928. return _macroTokenToFormatOpts[token];
  929. };
  930. function Formatter(locale, formatOpts) {
  931. this.opts = formatOpts;
  932. this.loc = locale;
  933. this.systemLoc = null;
  934. }
  935. var _proto = Formatter.prototype;
  936. _proto.formatWithSystemDefault = function formatWithSystemDefault(dt, opts) {
  937. if (this.systemLoc === null) {
  938. this.systemLoc = this.loc.redefaultToSystem();
  939. }
  940. var df = this.systemLoc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  941. return df.format();
  942. };
  943. _proto.formatDateTime = function formatDateTime(dt, opts) {
  944. if (opts === void 0) {
  945. opts = {};
  946. }
  947. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  948. return df.format();
  949. };
  950. _proto.formatDateTimeParts = function formatDateTimeParts(dt, opts) {
  951. if (opts === void 0) {
  952. opts = {};
  953. }
  954. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  955. return df.formatToParts();
  956. };
  957. _proto.resolvedOptions = function resolvedOptions(dt, opts) {
  958. if (opts === void 0) {
  959. opts = {};
  960. }
  961. var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
  962. return df.resolvedOptions();
  963. };
  964. _proto.num = function num(n, p) {
  965. if (p === void 0) {
  966. p = 0;
  967. }
  968. // we get some perf out of doing this here, annoyingly
  969. if (this.opts.forceSimple) {
  970. return padStart(n, p);
  971. }
  972. var opts = Object.assign({}, this.opts);
  973. if (p > 0) {
  974. opts.padTo = p;
  975. }
  976. return this.loc.numberFormatter(opts).format(n);
  977. };
  978. _proto.formatDateTimeFromString = function formatDateTimeFromString(dt, fmt) {
  979. var _this = this;
  980. var knownEnglish = this.loc.listingMode() === "en",
  981. useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory" && hasFormatToParts(),
  982. string = function string(opts, extract) {
  983. return _this.loc.extract(dt, opts, extract);
  984. },
  985. formatOffset = function formatOffset(opts) {
  986. if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
  987. return "Z";
  988. }
  989. return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
  990. },
  991. meridiem = function meridiem() {
  992. return knownEnglish ? meridiemForDateTime(dt) : string({
  993. hour: "numeric",
  994. hour12: true
  995. }, "dayperiod");
  996. },
  997. month = function month(length, standalone) {
  998. return knownEnglish ? monthForDateTime(dt, length) : string(standalone ? {
  999. month: length
  1000. } : {
  1001. month: length,
  1002. day: "numeric"
  1003. }, "month");
  1004. },
  1005. weekday = function weekday(length, standalone) {
  1006. return knownEnglish ? weekdayForDateTime(dt, length) : string(standalone ? {
  1007. weekday: length
  1008. } : {
  1009. weekday: length,
  1010. month: "long",
  1011. day: "numeric"
  1012. }, "weekday");
  1013. },
  1014. maybeMacro = function maybeMacro(token) {
  1015. var formatOpts = Formatter.macroTokenToFormatOpts(token);
  1016. if (formatOpts) {
  1017. return _this.formatWithSystemDefault(dt, formatOpts);
  1018. } else {
  1019. return token;
  1020. }
  1021. },
  1022. era = function era(length) {
  1023. return knownEnglish ? eraForDateTime(dt, length) : string({
  1024. era: length
  1025. }, "era");
  1026. },
  1027. tokenToString = function tokenToString(token) {
  1028. // Where possible: http://cldr.unicode.org/translation/date-time#TOC-Stand-Alone-vs.-Format-Styles
  1029. switch (token) {
  1030. // ms
  1031. case "S":
  1032. return _this.num(dt.millisecond);
  1033. case "u": // falls through
  1034. case "SSS":
  1035. return _this.num(dt.millisecond, 3);
  1036. // seconds
  1037. case "s":
  1038. return _this.num(dt.second);
  1039. case "ss":
  1040. return _this.num(dt.second, 2);
  1041. // minutes
  1042. case "m":
  1043. return _this.num(dt.minute);
  1044. case "mm":
  1045. return _this.num(dt.minute, 2);
  1046. // hours
  1047. case "h":
  1048. return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12);
  1049. case "hh":
  1050. return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2);
  1051. case "H":
  1052. return _this.num(dt.hour);
  1053. case "HH":
  1054. return _this.num(dt.hour, 2);
  1055. // offset
  1056. case "Z":
  1057. // like +6
  1058. return formatOffset({
  1059. format: "narrow",
  1060. allowZ: _this.opts.allowZ
  1061. });
  1062. case "ZZ":
  1063. // like +06:00
  1064. return formatOffset({
  1065. format: "short",
  1066. allowZ: _this.opts.allowZ
  1067. });
  1068. case "ZZZ":
  1069. // like +0600
  1070. return formatOffset({
  1071. format: "techie",
  1072. allowZ: false
  1073. });
  1074. case "ZZZZ":
  1075. // like EST
  1076. return dt.zone.offsetName(dt.ts, {
  1077. format: "short",
  1078. locale: _this.loc.locale
  1079. });
  1080. case "ZZZZZ":
  1081. // like Eastern Standard Time
  1082. return dt.zone.offsetName(dt.ts, {
  1083. format: "long",
  1084. locale: _this.loc.locale
  1085. });
  1086. // zone
  1087. case "z":
  1088. // like America/New_York
  1089. return dt.zoneName;
  1090. // meridiems
  1091. case "a":
  1092. return meridiem();
  1093. // dates
  1094. case "d":
  1095. return useDateTimeFormatter ? string({
  1096. day: "numeric"
  1097. }, "day") : _this.num(dt.day);
  1098. case "dd":
  1099. return useDateTimeFormatter ? string({
  1100. day: "2-digit"
  1101. }, "day") : _this.num(dt.day, 2);
  1102. // weekdays - standalone
  1103. case "c":
  1104. // like 1
  1105. return _this.num(dt.weekday);
  1106. case "ccc":
  1107. // like 'Tues'
  1108. return weekday("short", true);
  1109. case "cccc":
  1110. // like 'Tuesday'
  1111. return weekday("long", true);
  1112. case "ccccc":
  1113. // like 'T'
  1114. return weekday("narrow", true);
  1115. // weekdays - format
  1116. case "E":
  1117. // like 1
  1118. return _this.num(dt.weekday);
  1119. case "EEE":
  1120. // like 'Tues'
  1121. return weekday("short", false);
  1122. case "EEEE":
  1123. // like 'Tuesday'
  1124. return weekday("long", false);
  1125. case "EEEEE":
  1126. // like 'T'
  1127. return weekday("narrow", false);
  1128. // months - standalone
  1129. case "L":
  1130. // like 1
  1131. return useDateTimeFormatter ? string({
  1132. month: "numeric",
  1133. day: "numeric"
  1134. }, "month") : _this.num(dt.month);
  1135. case "LL":
  1136. // like 01, doesn't seem to work
  1137. return useDateTimeFormatter ? string({
  1138. month: "2-digit",
  1139. day: "numeric"
  1140. }, "month") : _this.num(dt.month, 2);
  1141. case "LLL":
  1142. // like Jan
  1143. return month("short", true);
  1144. case "LLLL":
  1145. // like January
  1146. return month("long", true);
  1147. case "LLLLL":
  1148. // like J
  1149. return month("narrow", true);
  1150. // months - format
  1151. case "M":
  1152. // like 1
  1153. return useDateTimeFormatter ? string({
  1154. month: "numeric"
  1155. }, "month") : _this.num(dt.month);
  1156. case "MM":
  1157. // like 01
  1158. return useDateTimeFormatter ? string({
  1159. month: "2-digit"
  1160. }, "month") : _this.num(dt.month, 2);
  1161. case "MMM":
  1162. // like Jan
  1163. return month("short", false);
  1164. case "MMMM":
  1165. // like January
  1166. return month("long", false);
  1167. case "MMMMM":
  1168. // like J
  1169. return month("narrow", false);
  1170. // years
  1171. case "y":
  1172. // like 2014
  1173. return useDateTimeFormatter ? string({
  1174. year: "numeric"
  1175. }, "year") : _this.num(dt.year);
  1176. case "yy":
  1177. // like 14
  1178. return useDateTimeFormatter ? string({
  1179. year: "2-digit"
  1180. }, "year") : _this.num(dt.year.toString().slice(-2), 2);
  1181. case "yyyy":
  1182. // like 0012
  1183. return useDateTimeFormatter ? string({
  1184. year: "numeric"
  1185. }, "year") : _this.num(dt.year, 4);
  1186. case "yyyyyy":
  1187. // like 000012
  1188. return useDateTimeFormatter ? string({
  1189. year: "numeric"
  1190. }, "year") : _this.num(dt.year, 6);
  1191. // eras
  1192. case "G":
  1193. // like AD
  1194. return era("short");
  1195. case "GG":
  1196. // like Anno Domini
  1197. return era("long");
  1198. case "GGGGG":
  1199. return era("narrow");
  1200. case "kk":
  1201. return _this.num(dt.weekYear.toString().slice(-2), 2);
  1202. case "kkkk":
  1203. return _this.num(dt.weekYear, 4);
  1204. case "W":
  1205. return _this.num(dt.weekNumber);
  1206. case "WW":
  1207. return _this.num(dt.weekNumber, 2);
  1208. case "o":
  1209. return _this.num(dt.ordinal);
  1210. case "ooo":
  1211. return _this.num(dt.ordinal, 3);
  1212. case "q":
  1213. // like 1
  1214. return _this.num(dt.quarter);
  1215. case "qq":
  1216. // like 01
  1217. return _this.num(dt.quarter, 2);
  1218. case "X":
  1219. return _this.num(Math.floor(dt.ts / 1000));
  1220. case "x":
  1221. return _this.num(dt.ts);
  1222. default:
  1223. return maybeMacro(token);
  1224. }
  1225. };
  1226. return stringifyTokens(Formatter.parseFormat(fmt), tokenToString);
  1227. };
  1228. _proto.formatDurationFromString = function formatDurationFromString(dur, fmt) {
  1229. var _this2 = this;
  1230. var tokenToField = function tokenToField(token) {
  1231. switch (token[0]) {
  1232. case "S":
  1233. return "millisecond";
  1234. case "s":
  1235. return "second";
  1236. case "m":
  1237. return "minute";
  1238. case "h":
  1239. return "hour";
  1240. case "d":
  1241. return "day";
  1242. case "M":
  1243. return "month";
  1244. case "y":
  1245. return "year";
  1246. default:
  1247. return null;
  1248. }
  1249. },
  1250. tokenToString = function tokenToString(lildur) {
  1251. return function (token) {
  1252. var mapped = tokenToField(token);
  1253. if (mapped) {
  1254. return _this2.num(lildur.get(mapped), token.length);
  1255. } else {
  1256. return token;
  1257. }
  1258. };
  1259. },
  1260. tokens = Formatter.parseFormat(fmt),
  1261. realTokens = tokens.reduce(function (found, _ref2) {
  1262. var literal = _ref2.literal,
  1263. val = _ref2.val;
  1264. return literal ? found : found.concat(val);
  1265. }, []),
  1266. collapsed = dur.shiftTo.apply(dur, realTokens.map(tokenToField).filter(function (t) {
  1267. return t;
  1268. }));
  1269. return stringifyTokens(tokens, tokenToString(collapsed));
  1270. };
  1271. return Formatter;
  1272. }();
  1273. var Invalid =
  1274. /*#__PURE__*/
  1275. function () {
  1276. function Invalid(reason, explanation) {
  1277. this.reason = reason;
  1278. this.explanation = explanation;
  1279. }
  1280. var _proto = Invalid.prototype;
  1281. _proto.toMessage = function toMessage() {
  1282. if (this.explanation) {
  1283. return this.reason + ": " + this.explanation;
  1284. } else {
  1285. return this.reason;
  1286. }
  1287. };
  1288. return Invalid;
  1289. }();
  1290. /**
  1291. * @interface
  1292. */
  1293. var Zone =
  1294. /*#__PURE__*/
  1295. function () {
  1296. function Zone() {}
  1297. var _proto = Zone.prototype;
  1298. /**
  1299. * Returns the offset's common name (such as EST) at the specified timestamp
  1300. * @abstract
  1301. * @param {number} ts - Epoch milliseconds for which to get the name
  1302. * @param {Object} opts - Options to affect the format
  1303. * @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
  1304. * @param {string} opts.locale - What locale to return the offset name in.
  1305. * @return {string}
  1306. */
  1307. _proto.offsetName = function offsetName(ts, opts) {
  1308. throw new ZoneIsAbstractError();
  1309. }
  1310. /**
  1311. * Returns the offset's value as a string
  1312. * @abstract
  1313. * @param {number} ts - Epoch milliseconds for which to get the offset
  1314. * @param {string} format - What style of offset to return.
  1315. * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
  1316. * @return {string}
  1317. */
  1318. ;
  1319. _proto.formatOffset = function formatOffset(ts, format) {
  1320. throw new ZoneIsAbstractError();
  1321. }
  1322. /**
  1323. * Return the offset in minutes for this zone at the specified timestamp.
  1324. * @abstract
  1325. * @param {number} ts - Epoch milliseconds for which to compute the offset
  1326. * @return {number}
  1327. */
  1328. ;
  1329. _proto.offset = function offset(ts) {
  1330. throw new ZoneIsAbstractError();
  1331. }
  1332. /**
  1333. * Return whether this Zone is equal to another zone
  1334. * @abstract
  1335. * @param {Zone} otherZone - the zone to compare
  1336. * @return {boolean}
  1337. */
  1338. ;
  1339. _proto.equals = function equals(otherZone) {
  1340. throw new ZoneIsAbstractError();
  1341. }
  1342. /**
  1343. * Return whether this Zone is valid.
  1344. * @abstract
  1345. * @type {boolean}
  1346. */
  1347. ;
  1348. _createClass(Zone, [{
  1349. key: "type",
  1350. /**
  1351. * The type of zone
  1352. * @abstract
  1353. * @type {string}
  1354. */
  1355. get: function get() {
  1356. throw new ZoneIsAbstractError();
  1357. }
  1358. /**
  1359. * The name of this zone.
  1360. * @abstract
  1361. * @type {string}
  1362. */
  1363. }, {
  1364. key: "name",
  1365. get: function get() {
  1366. throw new ZoneIsAbstractError();
  1367. }
  1368. /**
  1369. * Returns whether the offset is known to be fixed for the whole year.
  1370. * @abstract
  1371. * @type {boolean}
  1372. */
  1373. }, {
  1374. key: "universal",
  1375. get: function get() {
  1376. throw new ZoneIsAbstractError();
  1377. }
  1378. }, {
  1379. key: "isValid",
  1380. get: function get() {
  1381. throw new ZoneIsAbstractError();
  1382. }
  1383. }]);
  1384. return Zone;
  1385. }();
  1386. var singleton = null;
  1387. /**
  1388. * Represents the local zone for this Javascript environment.
  1389. * @implements {Zone}
  1390. */
  1391. var LocalZone =
  1392. /*#__PURE__*/
  1393. function (_Zone) {
  1394. _inheritsLoose(LocalZone, _Zone);
  1395. function LocalZone() {
  1396. return _Zone.apply(this, arguments) || this;
  1397. }
  1398. var _proto = LocalZone.prototype;
  1399. /** @override **/
  1400. _proto.offsetName = function offsetName(ts, _ref) {
  1401. var format = _ref.format,
  1402. locale = _ref.locale;
  1403. return parseZoneInfo(ts, format, locale);
  1404. }
  1405. /** @override **/
  1406. ;
  1407. _proto.formatOffset = function formatOffset$1(ts, format) {
  1408. return formatOffset(this.offset(ts), format);
  1409. }
  1410. /** @override **/
  1411. ;
  1412. _proto.offset = function offset(ts) {
  1413. return -new Date(ts).getTimezoneOffset();
  1414. }
  1415. /** @override **/
  1416. ;
  1417. _proto.equals = function equals(otherZone) {
  1418. return otherZone.type === "local";
  1419. }
  1420. /** @override **/
  1421. ;
  1422. _createClass(LocalZone, [{
  1423. key: "type",
  1424. /** @override **/
  1425. get: function get() {
  1426. return "local";
  1427. }
  1428. /** @override **/
  1429. }, {
  1430. key: "name",
  1431. get: function get() {
  1432. if (hasIntl()) {
  1433. return new Intl.DateTimeFormat().resolvedOptions().timeZone;
  1434. } else return "local";
  1435. }
  1436. /** @override **/
  1437. }, {
  1438. key: "universal",
  1439. get: function get() {
  1440. return false;
  1441. }
  1442. }, {
  1443. key: "isValid",
  1444. get: function get() {
  1445. return true;
  1446. }
  1447. }], [{
  1448. key: "instance",
  1449. /**
  1450. * Get a singleton instance of the local zone
  1451. * @return {LocalZone}
  1452. */
  1453. get: function get() {
  1454. if (singleton === null) {
  1455. singleton = new LocalZone();
  1456. }
  1457. return singleton;
  1458. }
  1459. }]);
  1460. return LocalZone;
  1461. }(Zone);
  1462. var matchingRegex = RegExp("^" + ianaRegex.source + "$");
  1463. var dtfCache = {};
  1464. function makeDTF(zone) {
  1465. if (!dtfCache[zone]) {
  1466. dtfCache[zone] = new Intl.DateTimeFormat("en-US", {
  1467. hour12: false,
  1468. timeZone: zone,
  1469. year: "numeric",
  1470. month: "2-digit",
  1471. day: "2-digit",
  1472. hour: "2-digit",
  1473. minute: "2-digit",
  1474. second: "2-digit"
  1475. });
  1476. }
  1477. return dtfCache[zone];
  1478. }
  1479. var typeToPos = {
  1480. year: 0,
  1481. month: 1,
  1482. day: 2,
  1483. hour: 3,
  1484. minute: 4,
  1485. second: 5
  1486. };
  1487. function hackyOffset(dtf, date) {
  1488. var formatted = dtf.format(date).replace(/\u200E/g, ""),
  1489. parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted),
  1490. fMonth = parsed[1],
  1491. fDay = parsed[2],
  1492. fYear = parsed[3],
  1493. fHour = parsed[4],
  1494. fMinute = parsed[5],
  1495. fSecond = parsed[6];
  1496. return [fYear, fMonth, fDay, fHour, fMinute, fSecond];
  1497. }
  1498. function partsOffset(dtf, date) {
  1499. var formatted = dtf.formatToParts(date),
  1500. filled = [];
  1501. for (var i = 0; i < formatted.length; i++) {
  1502. var _formatted$i = formatted[i],
  1503. type = _formatted$i.type,
  1504. value = _formatted$i.value,
  1505. pos = typeToPos[type];
  1506. if (!isUndefined(pos)) {
  1507. filled[pos] = parseInt(value, 10);
  1508. }
  1509. }
  1510. return filled;
  1511. }
  1512. var ianaZoneCache = {};
  1513. /**
  1514. * A zone identified by an IANA identifier, like America/New_York
  1515. * @implements {Zone}
  1516. */
  1517. var IANAZone =
  1518. /*#__PURE__*/
  1519. function (_Zone) {
  1520. _inheritsLoose(IANAZone, _Zone);
  1521. /**
  1522. * @param {string} name - Zone name
  1523. * @return {IANAZone}
  1524. */
  1525. IANAZone.create = function create(name) {
  1526. if (!ianaZoneCache[name]) {
  1527. ianaZoneCache[name] = new IANAZone(name);
  1528. }
  1529. return ianaZoneCache[name];
  1530. }
  1531. /**
  1532. * Reset local caches. Should only be necessary in testing scenarios.
  1533. * @return {void}
  1534. */
  1535. ;
  1536. IANAZone.resetCache = function resetCache() {
  1537. ianaZoneCache = {};
  1538. dtfCache = {};
  1539. }
  1540. /**
  1541. * 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.
  1542. * @param {string} s - The string to check validity on
  1543. * @example IANAZone.isValidSpecifier("America/New_York") //=> true
  1544. * @example IANAZone.isValidSpecifier("Fantasia/Castle") //=> true
  1545. * @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false
  1546. * @return {boolean}
  1547. */
  1548. ;
  1549. IANAZone.isValidSpecifier = function isValidSpecifier(s) {
  1550. return !!(s && s.match(matchingRegex));
  1551. }
  1552. /**
  1553. * Returns whether the provided string identifies a real zone
  1554. * @param {string} zone - The string to check
  1555. * @example IANAZone.isValidZone("America/New_York") //=> true
  1556. * @example IANAZone.isValidZone("Fantasia/Castle") //=> false
  1557. * @example IANAZone.isValidZone("Sport~~blorp") //=> false
  1558. * @return {boolean}
  1559. */
  1560. ;
  1561. IANAZone.isValidZone = function isValidZone(zone) {
  1562. try {
  1563. new Intl.DateTimeFormat("en-US", {
  1564. timeZone: zone
  1565. }).format();
  1566. return true;
  1567. } catch (e) {
  1568. return false;
  1569. }
  1570. } // Etc/GMT+8 -> -480
  1571. /** @ignore */
  1572. ;
  1573. IANAZone.parseGMTOffset = function parseGMTOffset(specifier) {
  1574. if (specifier) {
  1575. var match = specifier.match(/^Etc\/GMT([+-]\d{1,2})$/i);
  1576. if (match) {
  1577. return -60 * parseInt(match[1]);
  1578. }
  1579. }
  1580. return null;
  1581. };
  1582. function IANAZone(name) {
  1583. var _this;
  1584. _this = _Zone.call(this) || this;
  1585. /** @private **/
  1586. _this.zoneName = name;
  1587. /** @private **/
  1588. _this.valid = IANAZone.isValidZone(name);
  1589. return _this;
  1590. }
  1591. /** @override **/
  1592. var _proto = IANAZone.prototype;
  1593. /** @override **/
  1594. _proto.offsetName = function offsetName(ts, _ref) {
  1595. var format = _ref.format,
  1596. locale = _ref.locale;
  1597. return parseZoneInfo(ts, format, locale, this.name);
  1598. }
  1599. /** @override **/
  1600. ;
  1601. _proto.formatOffset = function formatOffset$1(ts, format) {
  1602. return formatOffset(this.offset(ts), format);
  1603. }
  1604. /** @override **/
  1605. ;
  1606. _proto.offset = function offset(ts) {
  1607. var date = new Date(ts),
  1608. dtf = makeDTF(this.name),
  1609. _ref2 = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date),
  1610. year = _ref2[0],
  1611. month = _ref2[1],
  1612. day = _ref2[2],
  1613. hour = _ref2[3],
  1614. minute = _ref2[4],
  1615. second = _ref2[5],
  1616. adjustedHour = hour === 24 ? 0 : hour;
  1617. var asUTC = objToLocalTS({
  1618. year: year,
  1619. month: month,
  1620. day: day,
  1621. hour: adjustedHour,
  1622. minute: minute,
  1623. second: second,
  1624. millisecond: 0
  1625. });
  1626. var asTS = date.valueOf();
  1627. asTS -= asTS % 1000;
  1628. return (asUTC - asTS) / (60 * 1000);
  1629. }
  1630. /** @override **/
  1631. ;
  1632. _proto.equals = function equals(otherZone) {
  1633. return otherZone.type === "iana" && otherZone.name === this.name;
  1634. }
  1635. /** @override **/
  1636. ;
  1637. _createClass(IANAZone, [{
  1638. key: "type",
  1639. get: function get() {
  1640. return "iana";
  1641. }
  1642. /** @override **/
  1643. }, {
  1644. key: "name",
  1645. get: function get() {
  1646. return this.zoneName;
  1647. }
  1648. /** @override **/
  1649. }, {
  1650. key: "universal",
  1651. get: function get() {
  1652. return false;
  1653. }
  1654. }, {
  1655. key: "isValid",
  1656. get: function get() {
  1657. return this.valid;
  1658. }
  1659. }]);
  1660. return IANAZone;
  1661. }(Zone);
  1662. var singleton$1 = null;
  1663. /**
  1664. * A zone with a fixed offset (meaning no DST)
  1665. * @implements {Zone}
  1666. */
  1667. var FixedOffsetZone =
  1668. /*#__PURE__*/
  1669. function (_Zone) {
  1670. _inheritsLoose(FixedOffsetZone, _Zone);
  1671. /**
  1672. * Get an instance with a specified offset
  1673. * @param {number} offset - The offset in minutes
  1674. * @return {FixedOffsetZone}
  1675. */
  1676. FixedOffsetZone.instance = function instance(offset) {
  1677. return offset === 0 ? FixedOffsetZone.utcInstance : new FixedOffsetZone(offset);
  1678. }
  1679. /**
  1680. * Get an instance of FixedOffsetZone from a UTC offset string, like "UTC+6"
  1681. * @param {string} s - The offset string to parse
  1682. * @example FixedOffsetZone.parseSpecifier("UTC+6")
  1683. * @example FixedOffsetZone.parseSpecifier("UTC+06")
  1684. * @example FixedOffsetZone.parseSpecifier("UTC-6:00")
  1685. * @return {FixedOffsetZone}
  1686. */
  1687. ;
  1688. FixedOffsetZone.parseSpecifier = function parseSpecifier(s) {
  1689. if (s) {
  1690. var r = s.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
  1691. if (r) {
  1692. return new FixedOffsetZone(signedOffset(r[1], r[2]));
  1693. }
  1694. }
  1695. return null;
  1696. };
  1697. _createClass(FixedOffsetZone, null, [{
  1698. key: "utcInstance",
  1699. /**
  1700. * Get a singleton instance of UTC
  1701. * @return {FixedOffsetZone}
  1702. */
  1703. get: function get() {
  1704. if (singleton$1 === null) {
  1705. singleton$1 = new FixedOffsetZone(0);
  1706. }
  1707. return singleton$1;
  1708. }
  1709. }]);
  1710. function FixedOffsetZone(offset) {
  1711. var _this;
  1712. _this = _Zone.call(this) || this;
  1713. /** @private **/
  1714. _this.fixed = offset;
  1715. return _this;
  1716. }
  1717. /** @override **/
  1718. var _proto = FixedOffsetZone.prototype;
  1719. /** @override **/
  1720. _proto.offsetName = function offsetName() {
  1721. return this.name;
  1722. }
  1723. /** @override **/
  1724. ;
  1725. _proto.formatOffset = function formatOffset$1(ts, format) {
  1726. return formatOffset(this.fixed, format);
  1727. }
  1728. /** @override **/
  1729. ;
  1730. /** @override **/
  1731. _proto.offset = function offset() {
  1732. return this.fixed;
  1733. }
  1734. /** @override **/
  1735. ;
  1736. _proto.equals = function equals(otherZone) {
  1737. return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
  1738. }
  1739. /** @override **/
  1740. ;
  1741. _createClass(FixedOffsetZone, [{
  1742. key: "type",
  1743. get: function get() {
  1744. return "fixed";
  1745. }
  1746. /** @override **/
  1747. }, {
  1748. key: "name",
  1749. get: function get() {
  1750. return this.fixed === 0 ? "UTC" : "UTC" + formatOffset(this.fixed, "narrow");
  1751. }
  1752. }, {
  1753. key: "universal",
  1754. get: function get() {
  1755. return true;
  1756. }
  1757. }, {
  1758. key: "isValid",
  1759. get: function get() {
  1760. return true;
  1761. }
  1762. }]);
  1763. return FixedOffsetZone;
  1764. }(Zone);
  1765. /**
  1766. * A zone that failed to parse. You should never need to instantiate this.
  1767. * @implements {Zone}
  1768. */
  1769. var InvalidZone =
  1770. /*#__PURE__*/
  1771. function (_Zone) {
  1772. _inheritsLoose(InvalidZone, _Zone);
  1773. function InvalidZone(zoneName) {
  1774. var _this;
  1775. _this = _Zone.call(this) || this;
  1776. /** @private */
  1777. _this.zoneName = zoneName;
  1778. return _this;
  1779. }
  1780. /** @override **/
  1781. var _proto = InvalidZone.prototype;
  1782. /** @override **/
  1783. _proto.offsetName = function offsetName() {
  1784. return null;
  1785. }
  1786. /** @override **/
  1787. ;
  1788. _proto.formatOffset = function formatOffset() {
  1789. return "";
  1790. }
  1791. /** @override **/
  1792. ;
  1793. _proto.offset = function offset() {
  1794. return NaN;
  1795. }
  1796. /** @override **/
  1797. ;
  1798. _proto.equals = function equals() {
  1799. return false;
  1800. }
  1801. /** @override **/
  1802. ;
  1803. _createClass(InvalidZone, [{
  1804. key: "type",
  1805. get: function get() {
  1806. return "invalid";
  1807. }
  1808. /** @override **/
  1809. }, {
  1810. key: "name",
  1811. get: function get() {
  1812. return this.zoneName;
  1813. }
  1814. /** @override **/
  1815. }, {
  1816. key: "universal",
  1817. get: function get() {
  1818. return false;
  1819. }
  1820. }, {
  1821. key: "isValid",
  1822. get: function get() {
  1823. return false;
  1824. }
  1825. }]);
  1826. return InvalidZone;
  1827. }(Zone);
  1828. /**
  1829. * @private
  1830. */
  1831. function normalizeZone(input, defaultZone) {
  1832. var offset;
  1833. if (isUndefined(input) || input === null) {
  1834. return defaultZone;
  1835. } else if (input instanceof Zone) {
  1836. return input;
  1837. } else if (isString(input)) {
  1838. var lowered = input.toLowerCase();
  1839. if (lowered === "local") return defaultZone;else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance;else if ((offset = IANAZone.parseGMTOffset(input)) != null) {
  1840. // handle Etc/GMT-4, which V8 chokes on
  1841. return FixedOffsetZone.instance(offset);
  1842. } else if (IANAZone.isValidSpecifier(lowered)) return IANAZone.create(input);else return FixedOffsetZone.parseSpecifier(lowered) || new InvalidZone(input);
  1843. } else if (isNumber(input)) {
  1844. return FixedOffsetZone.instance(input);
  1845. } else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
  1846. // This is dumb, but the instanceof check above doesn't seem to really work
  1847. // so we're duck checking it
  1848. return input;
  1849. } else {
  1850. return new InvalidZone(input);
  1851. }
  1852. }
  1853. var now = function now() {
  1854. return Date.now();
  1855. },
  1856. defaultZone = null,
  1857. // not setting this directly to LocalZone.instance bc loading order issues
  1858. defaultLocale = null,
  1859. defaultNumberingSystem = null,
  1860. defaultOutputCalendar = null,
  1861. throwOnInvalid = false;
  1862. /**
  1863. * 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.
  1864. */
  1865. var Settings =
  1866. /*#__PURE__*/
  1867. function () {
  1868. function Settings() {}
  1869. /**
  1870. * Reset Luxon's global caches. Should only be necessary in testing scenarios.
  1871. * @return {void}
  1872. */
  1873. Settings.resetCaches = function resetCaches() {
  1874. Locale.resetCache();
  1875. IANAZone.resetCache();
  1876. };
  1877. _createClass(Settings, null, [{
  1878. key: "now",
  1879. /**
  1880. * Get the callback for returning the current timestamp.
  1881. * @type {function}
  1882. */
  1883. get: function get() {
  1884. return now;
  1885. }
  1886. /**
  1887. * Set the callback for returning the current timestamp.
  1888. * The function should return a number, which will be interpreted as an Epoch millisecond count
  1889. * @type {function}
  1890. * @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
  1891. * @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
  1892. */
  1893. ,
  1894. set: function set(n) {
  1895. now = n;
  1896. }
  1897. /**
  1898. * Get the default time zone to create DateTimes in.
  1899. * @type {string}
  1900. */
  1901. }, {
  1902. key: "defaultZoneName",
  1903. get: function get() {
  1904. return Settings.defaultZone.name;
  1905. }
  1906. /**
  1907. * Set the default time zone to create DateTimes in. Does not affect existing instances.
  1908. * @type {string}
  1909. */
  1910. ,
  1911. set: function set(z) {
  1912. if (!z) {
  1913. defaultZone = null;
  1914. } else {
  1915. defaultZone = normalizeZone(z);
  1916. }
  1917. }
  1918. /**
  1919. * Get the default time zone object to create DateTimes in. Does not affect existing instances.
  1920. * @type {Zone}
  1921. */
  1922. }, {
  1923. key: "defaultZone",
  1924. get: function get() {
  1925. return defaultZone || LocalZone.instance;
  1926. }
  1927. /**
  1928. * Get the default locale to create DateTimes with. Does not affect existing instances.
  1929. * @type {string}
  1930. */
  1931. }, {
  1932. key: "defaultLocale",
  1933. get: function get() {
  1934. return defaultLocale;
  1935. }
  1936. /**
  1937. * Set the default locale to create DateTimes with. Does not affect existing instances.
  1938. * @type {string}
  1939. */
  1940. ,
  1941. set: function set(locale) {
  1942. defaultLocale = locale;
  1943. }
  1944. /**
  1945. * Get the default numbering system to create DateTimes with. Does not affect existing instances.
  1946. * @type {string}
  1947. */
  1948. }, {
  1949. key: "defaultNumberingSystem",
  1950. get: function get() {
  1951. return defaultNumberingSystem;
  1952. }
  1953. /**
  1954. * Set the default numbering system to create DateTimes with. Does not affect existing instances.
  1955. * @type {string}
  1956. */
  1957. ,
  1958. set: function set(numberingSystem) {
  1959. defaultNumberingSystem = numberingSystem;
  1960. }
  1961. /**
  1962. * Get the default output calendar to create DateTimes with. Does not affect existing instances.
  1963. * @type {string}
  1964. */
  1965. }, {
  1966. key: "defaultOutputCalendar",
  1967. get: function get() {
  1968. return defaultOutputCalendar;
  1969. }
  1970. /**
  1971. * Set the default output calendar to create DateTimes with. Does not affect existing instances.
  1972. * @type {string}
  1973. */
  1974. ,
  1975. set: function set(outputCalendar) {
  1976. defaultOutputCalendar = outputCalendar;
  1977. }
  1978. /**
  1979. * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  1980. * @type {boolean}
  1981. */
  1982. }, {
  1983. key: "throwOnInvalid",
  1984. get: function get() {
  1985. return throwOnInvalid;
  1986. }
  1987. /**
  1988. * Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
  1989. * @type {boolean}
  1990. */
  1991. ,
  1992. set: function set(t) {
  1993. throwOnInvalid = t;
  1994. }
  1995. }]);
  1996. return Settings;
  1997. }();
  1998. var intlDTCache = {};
  1999. function getCachedDTF(locString, opts) {
  2000. if (opts === void 0) {
  2001. opts = {};
  2002. }
  2003. var key = JSON.stringify([locString, opts]);
  2004. var dtf = intlDTCache[key];
  2005. if (!dtf) {
  2006. dtf = new Intl.DateTimeFormat(locString, opts);
  2007. intlDTCache[key] = dtf;
  2008. }
  2009. return dtf;
  2010. }
  2011. var intlNumCache = {};
  2012. function getCachedINF(locString, opts) {
  2013. if (opts === void 0) {
  2014. opts = {};
  2015. }
  2016. var key = JSON.stringify([locString, opts]);
  2017. var inf = intlNumCache[key];
  2018. if (!inf) {
  2019. inf = new Intl.NumberFormat(locString, opts);
  2020. intlNumCache[key] = inf;
  2021. }
  2022. return inf;
  2023. }
  2024. var intlRelCache = {};
  2025. function getCachedRTF(locString, opts) {
  2026. if (opts === void 0) {
  2027. opts = {};
  2028. }
  2029. var key = JSON.stringify([locString, opts]);
  2030. var inf = intlRelCache[key];
  2031. if (!inf) {
  2032. inf = new Intl.RelativeTimeFormat(locString, opts);
  2033. intlRelCache[key] = inf;
  2034. }
  2035. return inf;
  2036. }
  2037. var sysLocaleCache = null;
  2038. function systemLocale() {
  2039. if (sysLocaleCache) {
  2040. return sysLocaleCache;
  2041. } else if (hasIntl()) {
  2042. var computedSys = new Intl.DateTimeFormat().resolvedOptions().locale; // node sometimes defaults to "und". Override that because that is dumb
  2043. sysLocaleCache = !computedSys || computedSys === "und" ? "en-US" : computedSys;
  2044. return sysLocaleCache;
  2045. } else {
  2046. sysLocaleCache = "en-US";
  2047. return sysLocaleCache;
  2048. }
  2049. }
  2050. function parseLocaleString(localeStr) {
  2051. // I really want to avoid writing a BCP 47 parser
  2052. // see, e.g. https://github.com/wooorm/bcp-47
  2053. // Instead, we'll do this:
  2054. // a) if the string has no -u extensions, just leave it alone
  2055. // b) if it does, use Intl to resolve everything
  2056. // c) if Intl fails, try again without the -u
  2057. var uIndex = localeStr.indexOf("-u-");
  2058. if (uIndex === -1) {
  2059. return [localeStr];
  2060. } else {
  2061. var options;
  2062. var smaller = localeStr.substring(0, uIndex);
  2063. try {
  2064. options = getCachedDTF(localeStr).resolvedOptions();
  2065. } catch (e) {
  2066. options = getCachedDTF(smaller).resolvedOptions();
  2067. }
  2068. var _options = options,
  2069. numberingSystem = _options.numberingSystem,
  2070. calendar = _options.calendar; // return the smaller one so that we can append the calendar and numbering overrides to it
  2071. return [smaller, numberingSystem, calendar];
  2072. }
  2073. }
  2074. function intlConfigString(localeStr, numberingSystem, outputCalendar) {
  2075. if (hasIntl()) {
  2076. if (outputCalendar || numberingSystem) {
  2077. localeStr += "-u";
  2078. if (outputCalendar) {
  2079. localeStr += "-ca-" + outputCalendar;
  2080. }
  2081. if (numberingSystem) {
  2082. localeStr += "-nu-" + numberingSystem;
  2083. }
  2084. return localeStr;
  2085. } else {
  2086. return localeStr;
  2087. }
  2088. } else {
  2089. return [];
  2090. }
  2091. }
  2092. function mapMonths(f) {
  2093. var ms = [];
  2094. for (var i = 1; i <= 12; i++) {
  2095. var dt = DateTime.utc(2016, i, 1);
  2096. ms.push(f(dt));
  2097. }
  2098. return ms;
  2099. }
  2100. function mapWeekdays(f) {
  2101. var ms = [];
  2102. for (var i = 1; i <= 7; i++) {
  2103. var dt = DateTime.utc(2016, 11, 13 + i);
  2104. ms.push(f(dt));
  2105. }
  2106. return ms;
  2107. }
  2108. function listStuff(loc, length, defaultOK, englishFn, intlFn) {
  2109. var mode = loc.listingMode(defaultOK);
  2110. if (mode === "error") {
  2111. return null;
  2112. } else if (mode === "en") {
  2113. return englishFn(length);
  2114. } else {
  2115. return intlFn(length);
  2116. }
  2117. }
  2118. function supportsFastNumbers(loc) {
  2119. if (loc.numberingSystem && loc.numberingSystem !== "latn") {
  2120. return false;
  2121. } else {
  2122. return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || hasIntl() && new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn";
  2123. }
  2124. }
  2125. /**
  2126. * @private
  2127. */
  2128. var PolyNumberFormatter =
  2129. /*#__PURE__*/
  2130. function () {
  2131. function PolyNumberFormatter(intl, forceSimple, opts) {
  2132. this.padTo = opts.padTo || 0;
  2133. this.floor = opts.floor || false;
  2134. if (!forceSimple && hasIntl()) {
  2135. var intlOpts = {
  2136. useGrouping: false
  2137. };
  2138. if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;
  2139. this.inf = getCachedINF(intl, intlOpts);
  2140. }
  2141. }
  2142. var _proto = PolyNumberFormatter.prototype;
  2143. _proto.format = function format(i) {
  2144. if (this.inf) {
  2145. var fixed = this.floor ? Math.floor(i) : i;
  2146. return this.inf.format(fixed);
  2147. } else {
  2148. // to match the browser's numberformatter defaults
  2149. var _fixed = this.floor ? Math.floor(i) : roundTo(i, 3);
  2150. return padStart(_fixed, this.padTo);
  2151. }
  2152. };
  2153. return PolyNumberFormatter;
  2154. }();
  2155. /**
  2156. * @private
  2157. */
  2158. var PolyDateFormatter =
  2159. /*#__PURE__*/
  2160. function () {
  2161. function PolyDateFormatter(dt, intl, opts) {
  2162. this.opts = opts;
  2163. this.hasIntl = hasIntl();
  2164. var z;
  2165. if (dt.zone.universal && this.hasIntl) {
  2166. // Chromium doesn't support fixed-offset zones like Etc/GMT+8 in its formatter,
  2167. // See https://bugs.chromium.org/p/chromium/issues/detail?id=364374.
  2168. // So we have to make do. Two cases:
  2169. // 1. The format options tell us to show the zone. We can't do that, so the best
  2170. // we can do is format the date in UTC.
  2171. // 2. The format options don't tell us to show the zone. Then we can adjust them
  2172. // the time and tell the formatter to show it to us in UTC, so that the time is right
  2173. // and the bad zone doesn't show up.
  2174. // We can clean all this up when Chrome fixes this.
  2175. z = "UTC";
  2176. if (opts.timeZoneName) {
  2177. this.dt = dt;
  2178. } else {
  2179. this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
  2180. }
  2181. } else if (dt.zone.type === "local") {
  2182. this.dt = dt;
  2183. } else {
  2184. this.dt = dt;
  2185. z = dt.zone.name;
  2186. }
  2187. if (this.hasIntl) {
  2188. var intlOpts = Object.assign({}, this.opts);
  2189. if (z) {
  2190. intlOpts.timeZone = z;
  2191. }
  2192. this.dtf = getCachedDTF(intl, intlOpts);
  2193. }
  2194. }
  2195. var _proto2 = PolyDateFormatter.prototype;
  2196. _proto2.format = function format() {
  2197. if (this.hasIntl) {
  2198. return this.dtf.format(this.dt.toJSDate());
  2199. } else {
  2200. var tokenFormat = formatString(this.opts),
  2201. loc = Locale.create("en-US");
  2202. return Formatter.create(loc).formatDateTimeFromString(this.dt, tokenFormat);
  2203. }
  2204. };
  2205. _proto2.formatToParts = function formatToParts() {
  2206. if (this.hasIntl && hasFormatToParts()) {
  2207. return this.dtf.formatToParts(this.dt.toJSDate());
  2208. } else {
  2209. // This is kind of a cop out. We actually could do this for English. However, we couldn't do it for intl strings
  2210. // and IMO it's too weird to have an uncanny valley like that
  2211. return [];
  2212. }
  2213. };
  2214. _proto2.resolvedOptions = function resolvedOptions() {
  2215. if (this.hasIntl) {
  2216. return this.dtf.resolvedOptions();
  2217. } else {
  2218. return {
  2219. locale: "en-US",
  2220. numberingSystem: "latn",
  2221. outputCalendar: "gregory"
  2222. };
  2223. }
  2224. };
  2225. return PolyDateFormatter;
  2226. }();
  2227. /**
  2228. * @private
  2229. */
  2230. var PolyRelFormatter =
  2231. /*#__PURE__*/
  2232. function () {
  2233. function PolyRelFormatter(intl, isEnglish, opts) {
  2234. this.opts = Object.assign({
  2235. style: "long"
  2236. }, opts);
  2237. if (!isEnglish && hasRelative()) {
  2238. this.rtf = getCachedRTF(intl, opts);
  2239. }
  2240. }
  2241. var _proto3 = PolyRelFormatter.prototype;
  2242. _proto3.format = function format(count, unit) {
  2243. if (this.rtf) {
  2244. return this.rtf.format(count, unit);
  2245. } else {
  2246. return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long");
  2247. }
  2248. };
  2249. _proto3.formatToParts = function formatToParts(count, unit) {
  2250. if (this.rtf) {
  2251. return this.rtf.formatToParts(count, unit);
  2252. } else {
  2253. return [];
  2254. }
  2255. };
  2256. return PolyRelFormatter;
  2257. }();
  2258. /**
  2259. * @private
  2260. */
  2261. var Locale =
  2262. /*#__PURE__*/
  2263. function () {
  2264. Locale.fromOpts = function fromOpts(opts) {
  2265. return Locale.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
  2266. };
  2267. Locale.create = function create(locale, numberingSystem, outputCalendar, defaultToEN) {
  2268. if (defaultToEN === void 0) {
  2269. defaultToEN = false;
  2270. }
  2271. var specifiedLocale = locale || Settings.defaultLocale,
  2272. // the system locale is useful for human readable strings but annoying for parsing/formatting known formats
  2273. localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale()),
  2274. numberingSystemR = numberingSystem || Settings.defaultNumberingSystem,
  2275. outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
  2276. return new Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
  2277. };
  2278. Locale.resetCache = function resetCache() {
  2279. sysLocaleCache = null;
  2280. intlDTCache = {};
  2281. intlNumCache = {};
  2282. intlRelCache = {};
  2283. };
  2284. Locale.fromObject = function fromObject(_temp) {
  2285. var _ref = _temp === void 0 ? {} : _temp,
  2286. locale = _ref.locale,
  2287. numberingSystem = _ref.numberingSystem,
  2288. outputCalendar = _ref.outputCalendar;
  2289. return Locale.create(locale, numberingSystem, outputCalendar);
  2290. };
  2291. function Locale(locale, numbering, outputCalendar, specifiedLocale) {
  2292. var _parseLocaleString = parseLocaleString(locale),
  2293. parsedLocale = _parseLocaleString[0],
  2294. parsedNumberingSystem = _parseLocaleString[1],
  2295. parsedOutputCalendar = _parseLocaleString[2];
  2296. this.locale = parsedLocale;
  2297. this.numberingSystem = numbering || parsedNumberingSystem || null;
  2298. this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
  2299. this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar);
  2300. this.weekdaysCache = {
  2301. format: {},
  2302. standalone: {}
  2303. };
  2304. this.monthsCache = {
  2305. format: {},
  2306. standalone: {}
  2307. };
  2308. this.meridiemCache = null;
  2309. this.eraCache = {};
  2310. this.specifiedLocale = specifiedLocale;
  2311. this.fastNumbersCached = null;
  2312. }
  2313. var _proto4 = Locale.prototype;
  2314. _proto4.listingMode = function listingMode(defaultOK) {
  2315. if (defaultOK === void 0) {
  2316. defaultOK = true;
  2317. }
  2318. var intl = hasIntl(),
  2319. hasFTP = intl && hasFormatToParts(),
  2320. isActuallyEn = this.isEnglish(),
  2321. hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
  2322. if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOK) {
  2323. return "error";
  2324. } else if (!hasFTP || isActuallyEn && hasNoWeirdness) {
  2325. return "en";
  2326. } else {
  2327. return "intl";
  2328. }
  2329. };
  2330. _proto4.clone = function clone(alts) {
  2331. if (!alts || Object.getOwnPropertyNames(alts).length === 0) {
  2332. return this;
  2333. } else {
  2334. return Locale.create(alts.locale || this.specifiedLocale, alts.numberingSystem || this.numberingSystem, alts.outputCalendar || this.outputCalendar, alts.defaultToEN || false);
  2335. }
  2336. };
  2337. _proto4.redefaultToEN = function redefaultToEN(alts) {
  2338. if (alts === void 0) {
  2339. alts = {};
  2340. }
  2341. return this.clone(Object.assign({}, alts, {
  2342. defaultToEN: true
  2343. }));
  2344. };
  2345. _proto4.redefaultToSystem = function redefaultToSystem(alts) {
  2346. if (alts === void 0) {
  2347. alts = {};
  2348. }
  2349. return this.clone(Object.assign({}, alts, {
  2350. defaultToEN: false
  2351. }));
  2352. };
  2353. _proto4.months = function months$1(length, format, defaultOK) {
  2354. var _this = this;
  2355. if (format === void 0) {
  2356. format = false;
  2357. }
  2358. if (defaultOK === void 0) {
  2359. defaultOK = true;
  2360. }
  2361. return listStuff(this, length, defaultOK, months, function () {
  2362. var intl = format ? {
  2363. month: length,
  2364. day: "numeric"
  2365. } : {
  2366. month: length
  2367. },
  2368. formatStr = format ? "format" : "standalone";
  2369. if (!_this.monthsCache[formatStr][length]) {
  2370. _this.monthsCache[formatStr][length] = mapMonths(function (dt) {
  2371. return _this.extract(dt, intl, "month");
  2372. });
  2373. }
  2374. return _this.monthsCache[formatStr][length];
  2375. });
  2376. };
  2377. _proto4.weekdays = function weekdays$1(length, format, defaultOK) {
  2378. var _this2 = this;
  2379. if (format === void 0) {
  2380. format = false;
  2381. }
  2382. if (defaultOK === void 0) {
  2383. defaultOK = true;
  2384. }
  2385. return listStuff(this, length, defaultOK, weekdays, function () {
  2386. var intl = format ? {
  2387. weekday: length,
  2388. year: "numeric",
  2389. month: "long",
  2390. day: "numeric"
  2391. } : {
  2392. weekday: length
  2393. },
  2394. formatStr = format ? "format" : "standalone";
  2395. if (!_this2.weekdaysCache[formatStr][length]) {
  2396. _this2.weekdaysCache[formatStr][length] = mapWeekdays(function (dt) {
  2397. return _this2.extract(dt, intl, "weekday");
  2398. });
  2399. }
  2400. return _this2.weekdaysCache[formatStr][length];
  2401. });
  2402. };
  2403. _proto4.meridiems = function meridiems$1(defaultOK) {
  2404. var _this3 = this;
  2405. if (defaultOK === void 0) {
  2406. defaultOK = true;
  2407. }
  2408. return listStuff(this, undefined, defaultOK, function () {
  2409. return meridiems;
  2410. }, function () {
  2411. // In theory there could be aribitrary day periods. We're gonna assume there are exactly two
  2412. // for AM and PM. This is probably wrong, but it's makes parsing way easier.
  2413. if (!_this3.meridiemCache) {
  2414. var intl = {
  2415. hour: "numeric",
  2416. hour12: true
  2417. };
  2418. _this3.meridiemCache = [DateTime.utc(2016, 11, 13, 9), DateTime.utc(2016, 11, 13, 19)].map(function (dt) {
  2419. return _this3.extract(dt, intl, "dayperiod");
  2420. });
  2421. }
  2422. return _this3.meridiemCache;
  2423. });
  2424. };
  2425. _proto4.eras = function eras$1(length, defaultOK) {
  2426. var _this4 = this;
  2427. if (defaultOK === void 0) {
  2428. defaultOK = true;
  2429. }
  2430. return listStuff(this, length, defaultOK, eras, function () {
  2431. var intl = {
  2432. era: length
  2433. }; // This is utter bullshit. Different calendars are going to define eras totally differently. What I need is the minimum set of dates
  2434. // to definitely enumerate them.
  2435. if (!_this4.eraCache[length]) {
  2436. _this4.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map(function (dt) {
  2437. return _this4.extract(dt, intl, "era");
  2438. });
  2439. }
  2440. return _this4.eraCache[length];
  2441. });
  2442. };
  2443. _proto4.extract = function extract(dt, intlOpts, field) {
  2444. var df = this.dtFormatter(dt, intlOpts),
  2445. results = df.formatToParts(),
  2446. matching = results.find(function (m) {
  2447. return m.type.toLowerCase() === field;
  2448. });
  2449. return matching ? matching.value : null;
  2450. };
  2451. _proto4.numberFormatter = function numberFormatter(opts) {
  2452. if (opts === void 0) {
  2453. opts = {};
  2454. }
  2455. // this forcesimple option is never used (the only caller short-circuits on it, but it seems safer to leave)
  2456. // (in contrast, the rest of the condition is used heavily)
  2457. return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts);
  2458. };
  2459. _proto4.dtFormatter = function dtFormatter(dt, intlOpts) {
  2460. if (intlOpts === void 0) {
  2461. intlOpts = {};
  2462. }
  2463. return new PolyDateFormatter(dt, this.intl, intlOpts);
  2464. };
  2465. _proto4.relFormatter = function relFormatter(opts) {
  2466. if (opts === void 0) {
  2467. opts = {};
  2468. }
  2469. return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
  2470. };
  2471. _proto4.isEnglish = function isEnglish() {
  2472. return this.locale === "en" || this.locale.toLowerCase() === "en-us" || hasIntl() && new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
  2473. };
  2474. _proto4.equals = function equals(other) {
  2475. return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
  2476. };
  2477. _createClass(Locale, [{
  2478. key: "fastNumbers",
  2479. get: function get() {
  2480. if (this.fastNumbersCached == null) {
  2481. this.fastNumbersCached = supportsFastNumbers(this);
  2482. }
  2483. return this.fastNumbersCached;
  2484. }
  2485. }]);
  2486. return Locale;
  2487. }();
  2488. /*
  2489. * This file handles parsing for well-specified formats. Here's how it works:
  2490. * Two things go into parsing: a regex to match with and an extractor to take apart the groups in the match.
  2491. * An extractor is just a function that takes a regex match array and returns a { year: ..., month: ... } object
  2492. * parse() does the work of executing the regex and applying the extractor. It takes multiple regex/extractor pairs to try in sequence.
  2493. * Extractors can take a "cursor" representing the offset in the match to look at. This makes it easy to combine extractors.
  2494. * combineExtractors() does the work of combining them, keeping track of the cursor through multiple extractions.
  2495. * Some extractions are super dumb and simpleParse and fromStrings help DRY them.
  2496. */
  2497. function combineRegexes() {
  2498. for (var _len = arguments.length, regexes = new Array(_len), _key = 0; _key < _len; _key++) {
  2499. regexes[_key] = arguments[_key];
  2500. }
  2501. var full = regexes.reduce(function (f, r) {
  2502. return f + r.source;
  2503. }, "");
  2504. return RegExp("^" + full + "$");
  2505. }
  2506. function combineExtractors() {
  2507. for (var _len2 = arguments.length, extractors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  2508. extractors[_key2] = arguments[_key2];
  2509. }
  2510. return function (m) {
  2511. return extractors.reduce(function (_ref, ex) {
  2512. var mergedVals = _ref[0],
  2513. mergedZone = _ref[1],
  2514. cursor = _ref[2];
  2515. var _ex = ex(m, cursor),
  2516. val = _ex[0],
  2517. zone = _ex[1],
  2518. next = _ex[2];
  2519. return [Object.assign(mergedVals, val), mergedZone || zone, next];
  2520. }, [{}, null, 1]).slice(0, 2);
  2521. };
  2522. }
  2523. function parse(s) {
  2524. if (s == null) {
  2525. return [null, null];
  2526. }
  2527. for (var _len3 = arguments.length, patterns = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  2528. patterns[_key3 - 1] = arguments[_key3];
  2529. }
  2530. for (var _i = 0, _patterns = patterns; _i < _patterns.length; _i++) {
  2531. var _patterns$_i = _patterns[_i],
  2532. regex = _patterns$_i[0],
  2533. extractor = _patterns$_i[1];
  2534. var m = regex.exec(s);
  2535. if (m) {
  2536. return extractor(m);
  2537. }
  2538. }
  2539. return [null, null];
  2540. }
  2541. function simpleParse() {
  2542. for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  2543. keys[_key4] = arguments[_key4];
  2544. }
  2545. return function (match, cursor) {
  2546. var ret = {};
  2547. var i;
  2548. for (i = 0; i < keys.length; i++) {
  2549. ret[keys[i]] = parseInteger(match[cursor + i]);
  2550. }
  2551. return [ret, null, cursor + i];
  2552. };
  2553. } // ISO and SQL parsing
  2554. var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,
  2555. isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,9}))?)?)?/,
  2556. isoTimeRegex = RegExp("" + isoTimeBaseRegex.source + offsetRegex.source + "?"),
  2557. isoTimeExtensionRegex = RegExp("(?:T" + isoTimeRegex.source + ")?"),
  2558. isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,
  2559. isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/,
  2560. isoOrdinalRegex = /(\d{4})-?(\d{3})/,
  2561. extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay"),
  2562. extractISOOrdinalData = simpleParse("year", "ordinal"),
  2563. sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/,
  2564. // dumbed-down version of the ISO one
  2565. sqlTimeRegex = RegExp(isoTimeBaseRegex.source + " ?(?:" + offsetRegex.source + "|(" + ianaRegex.source + "))?"),
  2566. sqlTimeExtensionRegex = RegExp("(?: " + sqlTimeRegex.source + ")?");
  2567. function int(match, pos, fallback) {
  2568. var m = match[pos];
  2569. return isUndefined(m) ? fallback : parseInteger(m);
  2570. }
  2571. function extractISOYmd(match, cursor) {
  2572. var item = {
  2573. year: int(match, cursor),
  2574. month: int(match, cursor + 1, 1),
  2575. day: int(match, cursor + 2, 1)
  2576. };
  2577. return [item, null, cursor + 3];
  2578. }
  2579. function extractISOTime(match, cursor) {
  2580. var item = {
  2581. hour: int(match, cursor, 0),
  2582. minute: int(match, cursor + 1, 0),
  2583. second: int(match, cursor + 2, 0),
  2584. millisecond: parseMillis(match[cursor + 3])
  2585. };
  2586. return [item, null, cursor + 4];
  2587. }
  2588. function extractISOOffset(match, cursor) {
  2589. var local = !match[cursor] && !match[cursor + 1],
  2590. fullOffset = signedOffset(match[cursor + 1], match[cursor + 2]),
  2591. zone = local ? null : FixedOffsetZone.instance(fullOffset);
  2592. return [{}, zone, cursor + 3];
  2593. }
  2594. function extractIANAZone(match, cursor) {
  2595. var zone = match[cursor] ? IANAZone.create(match[cursor]) : null;
  2596. return [{}, zone, cursor + 1];
  2597. } // ISO duration parsing
  2598. 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)?)?)$/;
  2599. function extractISODuration(match) {
  2600. var yearStr = match[1],
  2601. monthStr = match[2],
  2602. weekStr = match[3],
  2603. dayStr = match[4],
  2604. hourStr = match[5],
  2605. minuteStr = match[6],
  2606. secondStr = match[7],
  2607. millisecondsStr = match[8];
  2608. return [{
  2609. years: parseInteger(yearStr),
  2610. months: parseInteger(monthStr),
  2611. weeks: parseInteger(weekStr),
  2612. days: parseInteger(dayStr),
  2613. hours: parseInteger(hourStr),
  2614. minutes: parseInteger(minuteStr),
  2615. seconds: parseInteger(secondStr),
  2616. milliseconds: parseMillis(millisecondsStr)
  2617. }];
  2618. } // These are a little braindead. EDT *should* tell us that we're in, say, America/New_York
  2619. // and not just that we're in -240 *right now*. But since I don't think these are used that often
  2620. // I'm just going to ignore that
  2621. var obsOffsets = {
  2622. GMT: 0,
  2623. EDT: -4 * 60,
  2624. EST: -5 * 60,
  2625. CDT: -5 * 60,
  2626. CST: -6 * 60,
  2627. MDT: -6 * 60,
  2628. MST: -7 * 60,
  2629. PDT: -7 * 60,
  2630. PST: -8 * 60
  2631. };
  2632. function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  2633. var result = {
  2634. year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr),
  2635. month: monthsShort.indexOf(monthStr) + 1,
  2636. day: parseInteger(dayStr),
  2637. hour: parseInteger(hourStr),
  2638. minute: parseInteger(minuteStr)
  2639. };
  2640. if (secondStr) result.second = parseInteger(secondStr);
  2641. if (weekdayStr) {
  2642. result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1;
  2643. }
  2644. return result;
  2645. } // RFC 2822/5322
  2646. 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)))$/;
  2647. function extractRFC2822(match) {
  2648. var weekdayStr = match[1],
  2649. dayStr = match[2],
  2650. monthStr = match[3],
  2651. yearStr = match[4],
  2652. hourStr = match[5],
  2653. minuteStr = match[6],
  2654. secondStr = match[7],
  2655. obsOffset = match[8],
  2656. milOffset = match[9],
  2657. offHourStr = match[10],
  2658. offMinuteStr = match[11],
  2659. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2660. var offset;
  2661. if (obsOffset) {
  2662. offset = obsOffsets[obsOffset];
  2663. } else if (milOffset) {
  2664. offset = 0;
  2665. } else {
  2666. offset = signedOffset(offHourStr, offMinuteStr);
  2667. }
  2668. return [result, new FixedOffsetZone(offset)];
  2669. }
  2670. function preprocessRFC2822(s) {
  2671. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  2672. return s.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
  2673. } // http date
  2674. 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$/,
  2675. 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$/,
  2676. 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})$/;
  2677. function extractRFC1123Or850(match) {
  2678. var weekdayStr = match[1],
  2679. dayStr = match[2],
  2680. monthStr = match[3],
  2681. yearStr = match[4],
  2682. hourStr = match[5],
  2683. minuteStr = match[6],
  2684. secondStr = match[7],
  2685. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2686. return [result, FixedOffsetZone.utcInstance];
  2687. }
  2688. function extractASCII(match) {
  2689. var weekdayStr = match[1],
  2690. monthStr = match[2],
  2691. dayStr = match[3],
  2692. hourStr = match[4],
  2693. minuteStr = match[5],
  2694. secondStr = match[6],
  2695. yearStr = match[7],
  2696. result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
  2697. return [result, FixedOffsetZone.utcInstance];
  2698. }
  2699. var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex);
  2700. var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex);
  2701. var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex);
  2702. var isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
  2703. var extractISOYmdTimeAndOffset = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset);
  2704. var extractISOWeekTimeAndOffset = combineExtractors(extractISOWeekData, extractISOTime, extractISOOffset);
  2705. var extractISOOrdinalDataAndTime = combineExtractors(extractISOOrdinalData, extractISOTime);
  2706. var extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
  2707. /**
  2708. * @private
  2709. */
  2710. function parseISODate(s) {
  2711. return parse(s, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDataAndTime], [isoTimeCombinedRegex, extractISOTimeAndOffset]);
  2712. }
  2713. function parseRFC2822Date(s) {
  2714. return parse(preprocessRFC2822(s), [rfc2822, extractRFC2822]);
  2715. }
  2716. function parseHTTPDate(s) {
  2717. return parse(s, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], [ascii, extractASCII]);
  2718. }
  2719. function parseISODuration(s) {
  2720. return parse(s, [isoDuration, extractISODuration]);
  2721. }
  2722. var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
  2723. var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
  2724. var extractISOYmdTimeOffsetAndIANAZone = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset, extractIANAZone);
  2725. var extractISOTimeOffsetAndIANAZone = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone);
  2726. function parseSQL(s) {
  2727. return parse(s, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeOffsetAndIANAZone], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]);
  2728. }
  2729. var INVALID = "Invalid Duration"; // unit conversion constants
  2730. var lowOrderMatrix = {
  2731. weeks: {
  2732. days: 7,
  2733. hours: 7 * 24,
  2734. minutes: 7 * 24 * 60,
  2735. seconds: 7 * 24 * 60 * 60,
  2736. milliseconds: 7 * 24 * 60 * 60 * 1000
  2737. },
  2738. days: {
  2739. hours: 24,
  2740. minutes: 24 * 60,
  2741. seconds: 24 * 60 * 60,
  2742. milliseconds: 24 * 60 * 60 * 1000
  2743. },
  2744. hours: {
  2745. minutes: 60,
  2746. seconds: 60 * 60,
  2747. milliseconds: 60 * 60 * 1000
  2748. },
  2749. minutes: {
  2750. seconds: 60,
  2751. milliseconds: 60 * 1000
  2752. },
  2753. seconds: {
  2754. milliseconds: 1000
  2755. }
  2756. },
  2757. casualMatrix = Object.assign({
  2758. years: {
  2759. months: 12,
  2760. weeks: 52,
  2761. days: 365,
  2762. hours: 365 * 24,
  2763. minutes: 365 * 24 * 60,
  2764. seconds: 365 * 24 * 60 * 60,
  2765. milliseconds: 365 * 24 * 60 * 60 * 1000
  2766. },
  2767. quarters: {
  2768. months: 3,
  2769. weeks: 13,
  2770. days: 91,
  2771. hours: 91 * 24,
  2772. minutes: 91 * 24 * 60,
  2773. milliseconds: 91 * 24 * 60 * 60 * 1000
  2774. },
  2775. months: {
  2776. weeks: 4,
  2777. days: 30,
  2778. hours: 30 * 24,
  2779. minutes: 30 * 24 * 60,
  2780. seconds: 30 * 24 * 60 * 60,
  2781. milliseconds: 30 * 24 * 60 * 60 * 1000
  2782. }
  2783. }, lowOrderMatrix),
  2784. daysInYearAccurate = 146097.0 / 400,
  2785. daysInMonthAccurate = 146097.0 / 4800,
  2786. accurateMatrix = Object.assign({
  2787. years: {
  2788. months: 12,
  2789. weeks: daysInYearAccurate / 7,
  2790. days: daysInYearAccurate,
  2791. hours: daysInYearAccurate * 24,
  2792. minutes: daysInYearAccurate * 24 * 60,
  2793. seconds: daysInYearAccurate * 24 * 60 * 60,
  2794. milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000
  2795. },
  2796. quarters: {
  2797. months: 3,
  2798. weeks: daysInYearAccurate / 28,
  2799. days: daysInYearAccurate / 4,
  2800. hours: daysInYearAccurate * 24 / 4,
  2801. minutes: daysInYearAccurate * 24 * 60 / 4,
  2802. seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
  2803. milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 / 4
  2804. },
  2805. months: {
  2806. weeks: daysInMonthAccurate / 7,
  2807. days: daysInMonthAccurate,
  2808. hours: daysInMonthAccurate * 24,
  2809. minutes: daysInMonthAccurate * 24 * 60,
  2810. seconds: daysInMonthAccurate * 24 * 60 * 60,
  2811. milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000
  2812. }
  2813. }, lowOrderMatrix); // units ordered by size
  2814. var orderedUnits = ["years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds"];
  2815. var reverseUnits = orderedUnits.slice(0).reverse(); // clone really means "create another instance just like this one, but with these changes"
  2816. function clone(dur, alts, clear) {
  2817. if (clear === void 0) {
  2818. clear = false;
  2819. }
  2820. // deep merge for vals
  2821. var conf = {
  2822. values: clear ? alts.values : Object.assign({}, dur.values, alts.values || {}),
  2823. loc: dur.loc.clone(alts.loc),
  2824. conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
  2825. };
  2826. return new Duration(conf);
  2827. }
  2828. function antiTrunc(n) {
  2829. return n < 0 ? Math.floor(n) : Math.ceil(n);
  2830. } // NB: mutates parameters
  2831. function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
  2832. var conv = matrix[toUnit][fromUnit],
  2833. raw = fromMap[fromUnit] / conv,
  2834. sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]),
  2835. // ok, so this is wild, but see the matrix in the tests
  2836. added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw);
  2837. toMap[toUnit] += added;
  2838. fromMap[fromUnit] -= added * conv;
  2839. } // NB: mutates parameters
  2840. function normalizeValues(matrix, vals) {
  2841. reverseUnits.reduce(function (previous, current) {
  2842. if (!isUndefined(vals[current])) {
  2843. if (previous) {
  2844. convert(matrix, vals, previous, vals, current);
  2845. }
  2846. return current;
  2847. } else {
  2848. return previous;
  2849. }
  2850. }, null);
  2851. }
  2852. /**
  2853. * 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.
  2854. *
  2855. * Here is a brief overview of commonly used methods and getters in Duration:
  2856. *
  2857. * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
  2858. * * **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.
  2859. * * **Configuration** See {@link Duration.locale} and {@link Duration.numberingSystem} accessors.
  2860. * * **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}.
  2861. * * **Output** To convert the Duration into other representations, see {@link Duration.as}, {@link Duration.toISO}, {@link Duration.toFormat}, and {@link Duration.toJSON}
  2862. *
  2863. * There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation.
  2864. */
  2865. var Duration =
  2866. /*#__PURE__*/
  2867. function () {
  2868. /**
  2869. * @private
  2870. */
  2871. function Duration(config) {
  2872. var accurate = config.conversionAccuracy === "longterm" || false;
  2873. /**
  2874. * @access private
  2875. */
  2876. this.values = config.values;
  2877. /**
  2878. * @access private
  2879. */
  2880. this.loc = config.loc || Locale.create();
  2881. /**
  2882. * @access private
  2883. */
  2884. this.conversionAccuracy = accurate ? "longterm" : "casual";
  2885. /**
  2886. * @access private
  2887. */
  2888. this.invalid = config.invalid || null;
  2889. /**
  2890. * @access private
  2891. */
  2892. this.matrix = accurate ? accurateMatrix : casualMatrix;
  2893. /**
  2894. * @access private
  2895. */
  2896. this.isLuxonDuration = true;
  2897. }
  2898. /**
  2899. * Create Duration from a number of milliseconds.
  2900. * @param {number} count of milliseconds
  2901. * @param {Object} opts - options for parsing
  2902. * @param {string} [opts.locale='en-US'] - the locale to use
  2903. * @param {string} opts.numberingSystem - the numbering system to use
  2904. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  2905. * @return {Duration}
  2906. */
  2907. Duration.fromMillis = function fromMillis(count, opts) {
  2908. return Duration.fromObject(Object.assign({
  2909. milliseconds: count
  2910. }, opts));
  2911. }
  2912. /**
  2913. * Create a Duration from a Javascript object with keys like 'years' and 'hours.
  2914. * If this object is empty then a zero milliseconds duration is returned.
  2915. * @param {Object} obj - the object to create the DateTime from
  2916. * @param {number} obj.years
  2917. * @param {number} obj.quarters
  2918. * @param {number} obj.months
  2919. * @param {number} obj.weeks
  2920. * @param {number} obj.days
  2921. * @param {number} obj.hours
  2922. * @param {number} obj.minutes
  2923. * @param {number} obj.seconds
  2924. * @param {number} obj.milliseconds
  2925. * @param {string} [obj.locale='en-US'] - the locale to use
  2926. * @param {string} obj.numberingSystem - the numbering system to use
  2927. * @param {string} [obj.conversionAccuracy='casual'] - the conversion system to use
  2928. * @return {Duration}
  2929. */
  2930. ;
  2931. Duration.fromObject = function fromObject(obj) {
  2932. if (obj == null || typeof obj !== "object") {
  2933. throw new InvalidArgumentError("Duration.fromObject: argument expected to be an object, got " + (obj === null ? "null" : typeof obj));
  2934. }
  2935. return new Duration({
  2936. 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
  2937. ]),
  2938. loc: Locale.fromObject(obj),
  2939. conversionAccuracy: obj.conversionAccuracy
  2940. });
  2941. }
  2942. /**
  2943. * Create a Duration from an ISO 8601 duration string.
  2944. * @param {string} text - text to parse
  2945. * @param {Object} opts - options for parsing
  2946. * @param {string} [opts.locale='en-US'] - the locale to use
  2947. * @param {string} opts.numberingSystem - the numbering system to use
  2948. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  2949. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
  2950. * @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
  2951. * @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
  2952. * @example Duration.fromISO('P5Y3M').toObject() //=> { years: 5, months: 3 }
  2953. * @return {Duration}
  2954. */
  2955. ;
  2956. Duration.fromISO = function fromISO(text, opts) {
  2957. var _parseISODuration = parseISODuration(text),
  2958. parsed = _parseISODuration[0];
  2959. if (parsed) {
  2960. var obj = Object.assign(parsed, opts);
  2961. return Duration.fromObject(obj);
  2962. } else {
  2963. return Duration.invalid("unparsable", "the input \"" + text + "\" can't be parsed as ISO 8601");
  2964. }
  2965. }
  2966. /**
  2967. * Create an invalid Duration.
  2968. * @param {string} reason - simple string of why this datetime is invalid. Should not contain parameters or anything else data-dependent
  2969. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  2970. * @return {Duration}
  2971. */
  2972. ;
  2973. Duration.invalid = function invalid(reason, explanation) {
  2974. if (explanation === void 0) {
  2975. explanation = null;
  2976. }
  2977. if (!reason) {
  2978. throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
  2979. }
  2980. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  2981. if (Settings.throwOnInvalid) {
  2982. throw new InvalidDurationError(invalid);
  2983. } else {
  2984. return new Duration({
  2985. invalid: invalid
  2986. });
  2987. }
  2988. }
  2989. /**
  2990. * @private
  2991. */
  2992. ;
  2993. Duration.normalizeUnit = function normalizeUnit(unit) {
  2994. var normalized = {
  2995. year: "years",
  2996. years: "years",
  2997. quarter: "quarters",
  2998. quarters: "quarters",
  2999. month: "months",
  3000. months: "months",
  3001. week: "weeks",
  3002. weeks: "weeks",
  3003. day: "days",
  3004. days: "days",
  3005. hour: "hours",
  3006. hours: "hours",
  3007. minute: "minutes",
  3008. minutes: "minutes",
  3009. second: "seconds",
  3010. seconds: "seconds",
  3011. millisecond: "milliseconds",
  3012. milliseconds: "milliseconds"
  3013. }[unit ? unit.toLowerCase() : unit];
  3014. if (!normalized) throw new InvalidUnitError(unit);
  3015. return normalized;
  3016. }
  3017. /**
  3018. * Check if an object is a Duration. Works across context boundaries
  3019. * @param {object} o
  3020. * @return {boolean}
  3021. */
  3022. ;
  3023. Duration.isDuration = function isDuration(o) {
  3024. return o && o.isLuxonDuration || false;
  3025. }
  3026. /**
  3027. * Get the locale of a Duration, such 'en-GB'
  3028. * @type {string}
  3029. */
  3030. ;
  3031. var _proto = Duration.prototype;
  3032. /**
  3033. * Returns a string representation of this Duration formatted according to the specified format string. You may use these tokens:
  3034. * * `S` for milliseconds
  3035. * * `s` for seconds
  3036. * * `m` for minutes
  3037. * * `h` for hours
  3038. * * `d` for days
  3039. * * `M` for months
  3040. * * `y` for years
  3041. * Notes:
  3042. * * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits
  3043. * * 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.
  3044. * @param {string} fmt - the format string
  3045. * @param {Object} opts - options
  3046. * @param {boolean} [opts.floor=true] - floor numerical values
  3047. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("y d s") //=> "1 6 2"
  3048. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("yy dd sss") //=> "01 06 002"
  3049. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toFormat("M S") //=> "12 518402000"
  3050. * @return {string}
  3051. */
  3052. _proto.toFormat = function toFormat(fmt, opts) {
  3053. if (opts === void 0) {
  3054. opts = {};
  3055. }
  3056. // reverse-compat since 1.2; we always round down now, never up, and we do it by default
  3057. var fmtOpts = Object.assign({}, opts, {
  3058. floor: opts.round !== false && opts.floor !== false
  3059. });
  3060. return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID;
  3061. }
  3062. /**
  3063. * Returns a Javascript object with this Duration's values.
  3064. * @param opts - options for generating the object
  3065. * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
  3066. * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
  3067. * @return {Object}
  3068. */
  3069. ;
  3070. _proto.toObject = function toObject(opts) {
  3071. if (opts === void 0) {
  3072. opts = {};
  3073. }
  3074. if (!this.isValid) return {};
  3075. var base = Object.assign({}, this.values);
  3076. if (opts.includeConfig) {
  3077. base.conversionAccuracy = this.conversionAccuracy;
  3078. base.numberingSystem = this.loc.numberingSystem;
  3079. base.locale = this.loc.locale;
  3080. }
  3081. return base;
  3082. }
  3083. /**
  3084. * Returns an ISO 8601-compliant string representation of this Duration.
  3085. * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
  3086. * @example Duration.fromObject({ years: 3, seconds: 45 }).toISO() //=> 'P3YT45S'
  3087. * @example Duration.fromObject({ months: 4, seconds: 45 }).toISO() //=> 'P4MT45S'
  3088. * @example Duration.fromObject({ months: 5 }).toISO() //=> 'P5M'
  3089. * @example Duration.fromObject({ minutes: 5 }).toISO() //=> 'PT5M'
  3090. * @example Duration.fromObject({ milliseconds: 6 }).toISO() //=> 'PT0.006S'
  3091. * @return {string}
  3092. */
  3093. ;
  3094. _proto.toISO = function toISO() {
  3095. // we could use the formatter, but this is an easier way to get the minimum string
  3096. if (!this.isValid) return null;
  3097. var s = "P";
  3098. if (this.years !== 0) s += this.years + "Y";
  3099. if (this.months !== 0 || this.quarters !== 0) s += this.months + this.quarters * 3 + "M";
  3100. if (this.weeks !== 0) s += this.weeks + "W";
  3101. if (this.days !== 0) s += this.days + "D";
  3102. if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0) s += "T";
  3103. if (this.hours !== 0) s += this.hours + "H";
  3104. if (this.minutes !== 0) s += this.minutes + "M";
  3105. if (this.seconds !== 0 || this.milliseconds !== 0) // this will handle "floating point madness" by removing extra decimal places
  3106. // https://stackoverflow.com/questions/588004/is-floating-point-math-broken
  3107. s += roundTo(this.seconds + this.milliseconds / 1000, 3) + "S";
  3108. if (s === "P") s += "T0S";
  3109. return s;
  3110. }
  3111. /**
  3112. * Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
  3113. * @return {string}
  3114. */
  3115. ;
  3116. _proto.toJSON = function toJSON() {
  3117. return this.toISO();
  3118. }
  3119. /**
  3120. * Returns an ISO 8601 representation of this Duration appropriate for use in debugging.
  3121. * @return {string}
  3122. */
  3123. ;
  3124. _proto.toString = function toString() {
  3125. return this.toISO();
  3126. }
  3127. /**
  3128. * Returns an milliseconds value of this Duration.
  3129. * @return {number}
  3130. */
  3131. ;
  3132. _proto.valueOf = function valueOf() {
  3133. return this.as("milliseconds");
  3134. }
  3135. /**
  3136. * Make this Duration longer by the specified amount. Return a newly-constructed Duration.
  3137. * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  3138. * @return {Duration}
  3139. */
  3140. ;
  3141. _proto.plus = function plus(duration) {
  3142. if (!this.isValid) return this;
  3143. var dur = friendlyDuration(duration),
  3144. result = {};
  3145. for (var _i = 0, _orderedUnits = orderedUnits; _i < _orderedUnits.length; _i++) {
  3146. var k = _orderedUnits[_i];
  3147. if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
  3148. result[k] = dur.get(k) + this.get(k);
  3149. }
  3150. }
  3151. return clone(this, {
  3152. values: result
  3153. }, true);
  3154. }
  3155. /**
  3156. * Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
  3157. * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  3158. * @return {Duration}
  3159. */
  3160. ;
  3161. _proto.minus = function minus(duration) {
  3162. if (!this.isValid) return this;
  3163. var dur = friendlyDuration(duration);
  3164. return this.plus(dur.negate());
  3165. }
  3166. /**
  3167. * Scale this Duration by the specified amount. Return a newly-constructed Duration.
  3168. * @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.
  3169. * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }
  3170. * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
  3171. * @return {Duration}
  3172. */
  3173. ;
  3174. _proto.mapUnits = function mapUnits(fn) {
  3175. if (!this.isValid) return this;
  3176. var result = {};
  3177. for (var _i2 = 0, _Object$keys = Object.keys(this.values); _i2 < _Object$keys.length; _i2++) {
  3178. var k = _Object$keys[_i2];
  3179. result[k] = asNumber(fn(this.values[k], k));
  3180. }
  3181. return clone(this, {
  3182. values: result
  3183. }, true);
  3184. }
  3185. /**
  3186. * Get the value of unit.
  3187. * @param {string} unit - a unit such as 'minute' or 'day'
  3188. * @example Duration.fromObject({years: 2, days: 3}).years //=> 2
  3189. * @example Duration.fromObject({years: 2, days: 3}).months //=> 0
  3190. * @example Duration.fromObject({years: 2, days: 3}).days //=> 3
  3191. * @return {number}
  3192. */
  3193. ;
  3194. _proto.get = function get(unit) {
  3195. return this[Duration.normalizeUnit(unit)];
  3196. }
  3197. /**
  3198. * "Set" the values of specified units. Return a newly-constructed Duration.
  3199. * @param {Object} values - a mapping of units to numbers
  3200. * @example dur.set({ years: 2017 })
  3201. * @example dur.set({ hours: 8, minutes: 30 })
  3202. * @return {Duration}
  3203. */
  3204. ;
  3205. _proto.set = function set(values) {
  3206. if (!this.isValid) return this;
  3207. var mixed = Object.assign(this.values, normalizeObject(values, Duration.normalizeUnit, []));
  3208. return clone(this, {
  3209. values: mixed
  3210. });
  3211. }
  3212. /**
  3213. * "Set" the locale and/or numberingSystem. Returns a newly-constructed Duration.
  3214. * @example dur.reconfigure({ locale: 'en-GB' })
  3215. * @return {Duration}
  3216. */
  3217. ;
  3218. _proto.reconfigure = function reconfigure(_temp) {
  3219. var _ref = _temp === void 0 ? {} : _temp,
  3220. locale = _ref.locale,
  3221. numberingSystem = _ref.numberingSystem,
  3222. conversionAccuracy = _ref.conversionAccuracy;
  3223. var loc = this.loc.clone({
  3224. locale: locale,
  3225. numberingSystem: numberingSystem
  3226. }),
  3227. opts = {
  3228. loc: loc
  3229. };
  3230. if (conversionAccuracy) {
  3231. opts.conversionAccuracy = conversionAccuracy;
  3232. }
  3233. return clone(this, opts);
  3234. }
  3235. /**
  3236. * Return the length of the duration in the specified unit.
  3237. * @param {string} unit - a unit such as 'minutes' or 'days'
  3238. * @example Duration.fromObject({years: 1}).as('days') //=> 365
  3239. * @example Duration.fromObject({years: 1}).as('months') //=> 12
  3240. * @example Duration.fromObject({hours: 60}).as('days') //=> 2.5
  3241. * @return {number}
  3242. */
  3243. ;
  3244. _proto.as = function as(unit) {
  3245. return this.isValid ? this.shiftTo(unit).get(unit) : NaN;
  3246. }
  3247. /**
  3248. * Reduce this Duration to its canonical representation in its current units.
  3249. * @example Duration.fromObject({ years: 2, days: 5000 }).normalize().toObject() //=> { years: 15, days: 255 }
  3250. * @example Duration.fromObject({ hours: 12, minutes: -45 }).normalize().toObject() //=> { hours: 11, minutes: 15 }
  3251. * @return {Duration}
  3252. */
  3253. ;
  3254. _proto.normalize = function normalize() {
  3255. if (!this.isValid) return this;
  3256. var vals = this.toObject();
  3257. normalizeValues(this.matrix, vals);
  3258. return clone(this, {
  3259. values: vals
  3260. }, true);
  3261. }
  3262. /**
  3263. * Convert this Duration into its representation in a different set of units.
  3264. * @example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }
  3265. * @return {Duration}
  3266. */
  3267. ;
  3268. _proto.shiftTo = function shiftTo() {
  3269. for (var _len = arguments.length, units = new Array(_len), _key = 0; _key < _len; _key++) {
  3270. units[_key] = arguments[_key];
  3271. }
  3272. if (!this.isValid) return this;
  3273. if (units.length === 0) {
  3274. return this;
  3275. }
  3276. units = units.map(function (u) {
  3277. return Duration.normalizeUnit(u);
  3278. });
  3279. var built = {},
  3280. accumulated = {},
  3281. vals = this.toObject();
  3282. var lastUnit;
  3283. normalizeValues(this.matrix, vals);
  3284. for (var _i3 = 0, _orderedUnits2 = orderedUnits; _i3 < _orderedUnits2.length; _i3++) {
  3285. var k = _orderedUnits2[_i3];
  3286. if (units.indexOf(k) >= 0) {
  3287. lastUnit = k;
  3288. var own = 0; // anything we haven't boiled down yet should get boiled to this unit
  3289. for (var ak in accumulated) {
  3290. own += this.matrix[ak][k] * accumulated[ak];
  3291. accumulated[ak] = 0;
  3292. } // plus anything that's already in this unit
  3293. if (isNumber(vals[k])) {
  3294. own += vals[k];
  3295. }
  3296. var i = Math.trunc(own);
  3297. built[k] = i;
  3298. accumulated[k] = own - i; // we'd like to absorb these fractions in another unit
  3299. // plus anything further down the chain that should be rolled up in to this
  3300. for (var down in vals) {
  3301. if (orderedUnits.indexOf(down) > orderedUnits.indexOf(k)) {
  3302. convert(this.matrix, vals, down, built, k);
  3303. }
  3304. } // otherwise, keep it in the wings to boil it later
  3305. } else if (isNumber(vals[k])) {
  3306. accumulated[k] = vals[k];
  3307. }
  3308. } // anything leftover becomes the decimal for the last unit
  3309. // lastUnit must be defined since units is not empty
  3310. for (var key in accumulated) {
  3311. if (accumulated[key] !== 0) {
  3312. built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key];
  3313. }
  3314. }
  3315. return clone(this, {
  3316. values: built
  3317. }, true).normalize();
  3318. }
  3319. /**
  3320. * Return the negative of this Duration.
  3321. * @example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }
  3322. * @return {Duration}
  3323. */
  3324. ;
  3325. _proto.negate = function negate() {
  3326. if (!this.isValid) return this;
  3327. var negated = {};
  3328. for (var _i4 = 0, _Object$keys2 = Object.keys(this.values); _i4 < _Object$keys2.length; _i4++) {
  3329. var k = _Object$keys2[_i4];
  3330. negated[k] = -this.values[k];
  3331. }
  3332. return clone(this, {
  3333. values: negated
  3334. }, true);
  3335. }
  3336. /**
  3337. * Get the years.
  3338. * @type {number}
  3339. */
  3340. ;
  3341. /**
  3342. * Equality check
  3343. * Two Durations are equal iff they have the same units and the same values for each unit.
  3344. * @param {Duration} other
  3345. * @return {boolean}
  3346. */
  3347. _proto.equals = function equals(other) {
  3348. if (!this.isValid || !other.isValid) {
  3349. return false;
  3350. }
  3351. if (!this.loc.equals(other.loc)) {
  3352. return false;
  3353. }
  3354. for (var _i5 = 0, _orderedUnits3 = orderedUnits; _i5 < _orderedUnits3.length; _i5++) {
  3355. var u = _orderedUnits3[_i5];
  3356. if (this.values[u] !== other.values[u]) {
  3357. return false;
  3358. }
  3359. }
  3360. return true;
  3361. };
  3362. _createClass(Duration, [{
  3363. key: "locale",
  3364. get: function get() {
  3365. return this.isValid ? this.loc.locale : null;
  3366. }
  3367. /**
  3368. * Get the numbering system of a Duration, such 'beng'. The numbering system is used when formatting the Duration
  3369. *
  3370. * @type {string}
  3371. */
  3372. }, {
  3373. key: "numberingSystem",
  3374. get: function get() {
  3375. return this.isValid ? this.loc.numberingSystem : null;
  3376. }
  3377. }, {
  3378. key: "years",
  3379. get: function get() {
  3380. return this.isValid ? this.values.years || 0 : NaN;
  3381. }
  3382. /**
  3383. * Get the quarters.
  3384. * @type {number}
  3385. */
  3386. }, {
  3387. key: "quarters",
  3388. get: function get() {
  3389. return this.isValid ? this.values.quarters || 0 : NaN;
  3390. }
  3391. /**
  3392. * Get the months.
  3393. * @type {number}
  3394. */
  3395. }, {
  3396. key: "months",
  3397. get: function get() {
  3398. return this.isValid ? this.values.months || 0 : NaN;
  3399. }
  3400. /**
  3401. * Get the weeks
  3402. * @type {number}
  3403. */
  3404. }, {
  3405. key: "weeks",
  3406. get: function get() {
  3407. return this.isValid ? this.values.weeks || 0 : NaN;
  3408. }
  3409. /**
  3410. * Get the days.
  3411. * @type {number}
  3412. */
  3413. }, {
  3414. key: "days",
  3415. get: function get() {
  3416. return this.isValid ? this.values.days || 0 : NaN;
  3417. }
  3418. /**
  3419. * Get the hours.
  3420. * @type {number}
  3421. */
  3422. }, {
  3423. key: "hours",
  3424. get: function get() {
  3425. return this.isValid ? this.values.hours || 0 : NaN;
  3426. }
  3427. /**
  3428. * Get the minutes.
  3429. * @type {number}
  3430. */
  3431. }, {
  3432. key: "minutes",
  3433. get: function get() {
  3434. return this.isValid ? this.values.minutes || 0 : NaN;
  3435. }
  3436. /**
  3437. * Get the seconds.
  3438. * @return {number}
  3439. */
  3440. }, {
  3441. key: "seconds",
  3442. get: function get() {
  3443. return this.isValid ? this.values.seconds || 0 : NaN;
  3444. }
  3445. /**
  3446. * Get the milliseconds.
  3447. * @return {number}
  3448. */
  3449. }, {
  3450. key: "milliseconds",
  3451. get: function get() {
  3452. return this.isValid ? this.values.milliseconds || 0 : NaN;
  3453. }
  3454. /**
  3455. * Returns whether the Duration is invalid. Invalid durations are returned by diff operations
  3456. * on invalid DateTimes or Intervals.
  3457. * @return {boolean}
  3458. */
  3459. }, {
  3460. key: "isValid",
  3461. get: function get() {
  3462. return this.invalid === null;
  3463. }
  3464. /**
  3465. * Returns an error code if this Duration became invalid, or null if the Duration is valid
  3466. * @return {string}
  3467. */
  3468. }, {
  3469. key: "invalidReason",
  3470. get: function get() {
  3471. return this.invalid ? this.invalid.reason : null;
  3472. }
  3473. /**
  3474. * Returns an explanation of why this Duration became invalid, or null if the Duration is valid
  3475. * @type {string}
  3476. */
  3477. }, {
  3478. key: "invalidExplanation",
  3479. get: function get() {
  3480. return this.invalid ? this.invalid.explanation : null;
  3481. }
  3482. }]);
  3483. return Duration;
  3484. }();
  3485. function friendlyDuration(durationish) {
  3486. if (isNumber(durationish)) {
  3487. return Duration.fromMillis(durationish);
  3488. } else if (Duration.isDuration(durationish)) {
  3489. return durationish;
  3490. } else if (typeof durationish === "object") {
  3491. return Duration.fromObject(durationish);
  3492. } else {
  3493. throw new InvalidArgumentError("Unknown duration argument " + durationish + " of type " + typeof durationish);
  3494. }
  3495. }
  3496. var INVALID$1 = "Invalid Interval"; // checks if the start is equal to or before the end
  3497. function validateStartEnd(start, end) {
  3498. if (!start || !start.isValid) {
  3499. return Interval.invalid("missing or invalid start");
  3500. } else if (!end || !end.isValid) {
  3501. return Interval.invalid("missing or invalid end");
  3502. } else if (end < start) {
  3503. 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());
  3504. } else {
  3505. return null;
  3506. }
  3507. }
  3508. /**
  3509. * 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.
  3510. *
  3511. * Here is a brief overview of the most commonly used methods and getters in Interval:
  3512. *
  3513. * * **Creation** To create an Interval, use {@link fromDateTimes}, {@link after}, {@link before}, or {@link fromISO}.
  3514. * * **Accessors** Use {@link start} and {@link end} to get the start and end.
  3515. * * **Interrogation** To analyze the Interval, use {@link count}, {@link length}, {@link hasSame}, {@link contains}, {@link isAfter}, or {@link isBefore}.
  3516. * * **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}.
  3517. * * **Comparison** To compare this Interval to another one, use {@link equals}, {@link overlaps}, {@link abutsStart}, {@link abutsEnd}, {@link engulfs}
  3518. * * **Output** To convert the Interval into other representations, see {@link toString}, {@link toISO}, {@link toISODate}, {@link toISOTime}, {@link toFormat}, and {@link toDuration}.
  3519. */
  3520. var Interval =
  3521. /*#__PURE__*/
  3522. function () {
  3523. /**
  3524. * @private
  3525. */
  3526. function Interval(config) {
  3527. /**
  3528. * @access private
  3529. */
  3530. this.s = config.start;
  3531. /**
  3532. * @access private
  3533. */
  3534. this.e = config.end;
  3535. /**
  3536. * @access private
  3537. */
  3538. this.invalid = config.invalid || null;
  3539. /**
  3540. * @access private
  3541. */
  3542. this.isLuxonInterval = true;
  3543. }
  3544. /**
  3545. * Create an invalid Interval.
  3546. * @param {string} reason - simple string of why this Interval is invalid. Should not contain parameters or anything else data-dependent
  3547. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  3548. * @return {Interval}
  3549. */
  3550. Interval.invalid = function invalid(reason, explanation) {
  3551. if (explanation === void 0) {
  3552. explanation = null;
  3553. }
  3554. if (!reason) {
  3555. throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
  3556. }
  3557. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  3558. if (Settings.throwOnInvalid) {
  3559. throw new InvalidIntervalError(invalid);
  3560. } else {
  3561. return new Interval({
  3562. invalid: invalid
  3563. });
  3564. }
  3565. }
  3566. /**
  3567. * Create an Interval from a start DateTime and an end DateTime. Inclusive of the start but not the end.
  3568. * @param {DateTime|Date|Object} start
  3569. * @param {DateTime|Date|Object} end
  3570. * @return {Interval}
  3571. */
  3572. ;
  3573. Interval.fromDateTimes = function fromDateTimes(start, end) {
  3574. var builtStart = friendlyDateTime(start),
  3575. builtEnd = friendlyDateTime(end);
  3576. var validateError = validateStartEnd(builtStart, builtEnd);
  3577. if (validateError == null) {
  3578. return new Interval({
  3579. start: builtStart,
  3580. end: builtEnd
  3581. });
  3582. } else {
  3583. return validateError;
  3584. }
  3585. }
  3586. /**
  3587. * Create an Interval from a start DateTime and a Duration to extend to.
  3588. * @param {DateTime|Date|Object} start
  3589. * @param {Duration|Object|number} duration - the length of the Interval.
  3590. * @return {Interval}
  3591. */
  3592. ;
  3593. Interval.after = function after(start, duration) {
  3594. var dur = friendlyDuration(duration),
  3595. dt = friendlyDateTime(start);
  3596. return Interval.fromDateTimes(dt, dt.plus(dur));
  3597. }
  3598. /**
  3599. * Create an Interval from an end DateTime and a Duration to extend backwards to.
  3600. * @param {DateTime|Date|Object} end
  3601. * @param {Duration|Object|number} duration - the length of the Interval.
  3602. * @return {Interval}
  3603. */
  3604. ;
  3605. Interval.before = function before(end, duration) {
  3606. var dur = friendlyDuration(duration),
  3607. dt = friendlyDateTime(end);
  3608. return Interval.fromDateTimes(dt.minus(dur), dt);
  3609. }
  3610. /**
  3611. * Create an Interval from an ISO 8601 string.
  3612. * Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats.
  3613. * @param {string} text - the ISO string to parse
  3614. * @param {Object} [opts] - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO}
  3615. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  3616. * @return {Interval}
  3617. */
  3618. ;
  3619. Interval.fromISO = function fromISO(text, opts) {
  3620. var _split = (text || "").split("/", 2),
  3621. s = _split[0],
  3622. e = _split[1];
  3623. if (s && e) {
  3624. var start = DateTime.fromISO(s, opts),
  3625. end = DateTime.fromISO(e, opts);
  3626. if (start.isValid && end.isValid) {
  3627. return Interval.fromDateTimes(start, end);
  3628. }
  3629. if (start.isValid) {
  3630. var dur = Duration.fromISO(e, opts);
  3631. if (dur.isValid) {
  3632. return Interval.after(start, dur);
  3633. }
  3634. } else if (end.isValid) {
  3635. var _dur = Duration.fromISO(s, opts);
  3636. if (_dur.isValid) {
  3637. return Interval.before(end, _dur);
  3638. }
  3639. }
  3640. }
  3641. return Interval.invalid("unparsable", "the input \"" + text + "\" can't be parsed asISO 8601");
  3642. }
  3643. /**
  3644. * Check if an object is an Interval. Works across context boundaries
  3645. * @param {object} o
  3646. * @return {boolean}
  3647. */
  3648. ;
  3649. Interval.isInterval = function isInterval(o) {
  3650. return o && o.isLuxonInterval || false;
  3651. }
  3652. /**
  3653. * Returns the start of the Interval
  3654. * @type {DateTime}
  3655. */
  3656. ;
  3657. var _proto = Interval.prototype;
  3658. /**
  3659. * Returns the length of the Interval in the specified unit.
  3660. * @param {string} unit - the unit (such as 'hours' or 'days') to return the length in.
  3661. * @return {number}
  3662. */
  3663. _proto.length = function length(unit) {
  3664. if (unit === void 0) {
  3665. unit = "milliseconds";
  3666. }
  3667. return this.isValid ? this.toDuration.apply(this, [unit]).get(unit) : NaN;
  3668. }
  3669. /**
  3670. * Returns the count of minutes, hours, days, months, or years included in the Interval, even in part.
  3671. * Unlike {@link length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
  3672. * asks 'what dates are included in this interval?', not 'how many days long is this interval?'
  3673. * @param {string} [unit='milliseconds'] - the unit of time to count.
  3674. * @return {number}
  3675. */
  3676. ;
  3677. _proto.count = function count(unit) {
  3678. if (unit === void 0) {
  3679. unit = "milliseconds";
  3680. }
  3681. if (!this.isValid) return NaN;
  3682. var start = this.start.startOf(unit),
  3683. end = this.end.startOf(unit);
  3684. return Math.floor(end.diff(start, unit).get(unit)) + 1;
  3685. }
  3686. /**
  3687. * Returns whether this Interval's start and end are both in the same unit of time
  3688. * @param {string} unit - the unit of time to check sameness on
  3689. * @return {boolean}
  3690. */
  3691. ;
  3692. _proto.hasSame = function hasSame(unit) {
  3693. return this.isValid ? this.e.minus(1).hasSame(this.s, unit) : false;
  3694. }
  3695. /**
  3696. * Return whether this Interval has the same start and end DateTimes.
  3697. * @return {boolean}
  3698. */
  3699. ;
  3700. _proto.isEmpty = function isEmpty() {
  3701. return this.s.valueOf() === this.e.valueOf();
  3702. }
  3703. /**
  3704. * Return whether this Interval's start is after the specified DateTime.
  3705. * @param {DateTime} dateTime
  3706. * @return {boolean}
  3707. */
  3708. ;
  3709. _proto.isAfter = function isAfter(dateTime) {
  3710. if (!this.isValid) return false;
  3711. return this.s > dateTime;
  3712. }
  3713. /**
  3714. * Return whether this Interval's end is before the specified DateTime.
  3715. * @param {DateTime} dateTime
  3716. * @return {boolean}
  3717. */
  3718. ;
  3719. _proto.isBefore = function isBefore(dateTime) {
  3720. if (!this.isValid) return false;
  3721. return this.e <= dateTime;
  3722. }
  3723. /**
  3724. * Return whether this Interval contains the specified DateTime.
  3725. * @param {DateTime} dateTime
  3726. * @return {boolean}
  3727. */
  3728. ;
  3729. _proto.contains = function contains(dateTime) {
  3730. if (!this.isValid) return false;
  3731. return this.s <= dateTime && this.e > dateTime;
  3732. }
  3733. /**
  3734. * "Sets" the start and/or end dates. Returns a newly-constructed Interval.
  3735. * @param {Object} values - the values to set
  3736. * @param {DateTime} values.start - the starting DateTime
  3737. * @param {DateTime} values.end - the ending DateTime
  3738. * @return {Interval}
  3739. */
  3740. ;
  3741. _proto.set = function set(_temp) {
  3742. var _ref = _temp === void 0 ? {} : _temp,
  3743. start = _ref.start,
  3744. end = _ref.end;
  3745. if (!this.isValid) return this;
  3746. return Interval.fromDateTimes(start || this.s, end || this.e);
  3747. }
  3748. /**
  3749. * Split this Interval at each of the specified DateTimes
  3750. * @param {...[DateTime]} dateTimes - the unit of time to count.
  3751. * @return {[Interval]}
  3752. */
  3753. ;
  3754. _proto.splitAt = function splitAt() {
  3755. var _this = this;
  3756. if (!this.isValid) return [];
  3757. for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
  3758. dateTimes[_key] = arguments[_key];
  3759. }
  3760. var sorted = dateTimes.map(friendlyDateTime).filter(function (d) {
  3761. return _this.contains(d);
  3762. }).sort(),
  3763. results = [];
  3764. var s = this.s,
  3765. i = 0;
  3766. while (s < this.e) {
  3767. var added = sorted[i] || this.e,
  3768. next = +added > +this.e ? this.e : added;
  3769. results.push(Interval.fromDateTimes(s, next));
  3770. s = next;
  3771. i += 1;
  3772. }
  3773. return results;
  3774. }
  3775. /**
  3776. * Split this Interval into smaller Intervals, each of the specified length.
  3777. * Left over time is grouped into a smaller interval
  3778. * @param {Duration|Object|number} duration - The length of each resulting interval.
  3779. * @return {[Interval]}
  3780. */
  3781. ;
  3782. _proto.splitBy = function splitBy(duration) {
  3783. var dur = friendlyDuration(duration);
  3784. if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
  3785. return [];
  3786. }
  3787. var s = this.s,
  3788. added,
  3789. next;
  3790. var results = [];
  3791. while (s < this.e) {
  3792. added = s.plus(dur);
  3793. next = +added > +this.e ? this.e : added;
  3794. results.push(Interval.fromDateTimes(s, next));
  3795. s = next;
  3796. }
  3797. return results;
  3798. }
  3799. /**
  3800. * Split this Interval into the specified number of smaller intervals.
  3801. * @param {number} numberOfParts - The number of Intervals to divide the Interval into.
  3802. * @return {[Interval]}
  3803. */
  3804. ;
  3805. _proto.divideEqually = function divideEqually(numberOfParts) {
  3806. if (!this.isValid) return [];
  3807. return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
  3808. }
  3809. /**
  3810. * Return whether this Interval overlaps with the specified Interval
  3811. * @param {Interval} other
  3812. * @return {boolean}
  3813. */
  3814. ;
  3815. _proto.overlaps = function overlaps(other) {
  3816. return this.e > other.s && this.s < other.e;
  3817. }
  3818. /**
  3819. * Return whether this Interval's end is adjacent to the specified Interval's start.
  3820. * @param {Interval} other
  3821. * @return {boolean}
  3822. */
  3823. ;
  3824. _proto.abutsStart = function abutsStart(other) {
  3825. if (!this.isValid) return false;
  3826. return +this.e === +other.s;
  3827. }
  3828. /**
  3829. * Return whether this Interval's start is adjacent to the specified Interval's end.
  3830. * @param {Interval} other
  3831. * @return {boolean}
  3832. */
  3833. ;
  3834. _proto.abutsEnd = function abutsEnd(other) {
  3835. if (!this.isValid) return false;
  3836. return +other.e === +this.s;
  3837. }
  3838. /**
  3839. * Return whether this Interval engulfs the start and end of the specified Interval.
  3840. * @param {Interval} other
  3841. * @return {boolean}
  3842. */
  3843. ;
  3844. _proto.engulfs = function engulfs(other) {
  3845. if (!this.isValid) return false;
  3846. return this.s <= other.s && this.e >= other.e;
  3847. }
  3848. /**
  3849. * Return whether this Interval has the same start and end as the specified Interval.
  3850. * @param {Interval} other
  3851. * @return {boolean}
  3852. */
  3853. ;
  3854. _proto.equals = function equals(other) {
  3855. if (!this.isValid || !other.isValid) {
  3856. return false;
  3857. }
  3858. return this.s.equals(other.s) && this.e.equals(other.e);
  3859. }
  3860. /**
  3861. * Return an Interval representing the intersection of this Interval and the specified Interval.
  3862. * Specifically, the resulting Interval has the maximum start time and the minimum end time of the two Intervals.
  3863. * Returns null if the intersection is empty, meaning, the intervals don't intersect.
  3864. * @param {Interval} other
  3865. * @return {Interval}
  3866. */
  3867. ;
  3868. _proto.intersection = function intersection(other) {
  3869. if (!this.isValid) return this;
  3870. var s = this.s > other.s ? this.s : other.s,
  3871. e = this.e < other.e ? this.e : other.e;
  3872. if (s > e) {
  3873. return null;
  3874. } else {
  3875. return Interval.fromDateTimes(s, e);
  3876. }
  3877. }
  3878. /**
  3879. * Return an Interval representing the union of this Interval and the specified Interval.
  3880. * Specifically, the resulting Interval has the minimum start time and the maximum end time of the two Intervals.
  3881. * @param {Interval} other
  3882. * @return {Interval}
  3883. */
  3884. ;
  3885. _proto.union = function union(other) {
  3886. if (!this.isValid) return this;
  3887. var s = this.s < other.s ? this.s : other.s,
  3888. e = this.e > other.e ? this.e : other.e;
  3889. return Interval.fromDateTimes(s, e);
  3890. }
  3891. /**
  3892. * Merge an array of Intervals into a equivalent minimal set of Intervals.
  3893. * Combines overlapping and adjacent Intervals.
  3894. * @param {[Interval]} intervals
  3895. * @return {[Interval]}
  3896. */
  3897. ;
  3898. Interval.merge = function merge(intervals) {
  3899. var _intervals$sort$reduc = intervals.sort(function (a, b) {
  3900. return a.s - b.s;
  3901. }).reduce(function (_ref2, item) {
  3902. var sofar = _ref2[0],
  3903. current = _ref2[1];
  3904. if (!current) {
  3905. return [sofar, item];
  3906. } else if (current.overlaps(item) || current.abutsStart(item)) {
  3907. return [sofar, current.union(item)];
  3908. } else {
  3909. return [sofar.concat([current]), item];
  3910. }
  3911. }, [[], null]),
  3912. found = _intervals$sort$reduc[0],
  3913. final = _intervals$sort$reduc[1];
  3914. if (final) {
  3915. found.push(final);
  3916. }
  3917. return found;
  3918. }
  3919. /**
  3920. * Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.
  3921. * @param {[Interval]} intervals
  3922. * @return {[Interval]}
  3923. */
  3924. ;
  3925. Interval.xor = function xor(intervals) {
  3926. var _Array$prototype;
  3927. var start = null,
  3928. currentCount = 0;
  3929. var results = [],
  3930. ends = intervals.map(function (i) {
  3931. return [{
  3932. time: i.s,
  3933. type: "s"
  3934. }, {
  3935. time: i.e,
  3936. type: "e"
  3937. }];
  3938. }),
  3939. flattened = (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, ends),
  3940. arr = flattened.sort(function (a, b) {
  3941. return a.time - b.time;
  3942. });
  3943. for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  3944. var _ref3;
  3945. if (_isArray) {
  3946. if (_i >= _iterator.length) break;
  3947. _ref3 = _iterator[_i++];
  3948. } else {
  3949. _i = _iterator.next();
  3950. if (_i.done) break;
  3951. _ref3 = _i.value;
  3952. }
  3953. var i = _ref3;
  3954. currentCount += i.type === "s" ? 1 : -1;
  3955. if (currentCount === 1) {
  3956. start = i.time;
  3957. } else {
  3958. if (start && +start !== +i.time) {
  3959. results.push(Interval.fromDateTimes(start, i.time));
  3960. }
  3961. start = null;
  3962. }
  3963. }
  3964. return Interval.merge(results);
  3965. }
  3966. /**
  3967. * Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.
  3968. * @param {...Interval} intervals
  3969. * @return {[Interval]}
  3970. */
  3971. ;
  3972. _proto.difference = function difference() {
  3973. var _this2 = this;
  3974. for (var _len2 = arguments.length, intervals = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3975. intervals[_key2] = arguments[_key2];
  3976. }
  3977. return Interval.xor([this].concat(intervals)).map(function (i) {
  3978. return _this2.intersection(i);
  3979. }).filter(function (i) {
  3980. return i && !i.isEmpty();
  3981. });
  3982. }
  3983. /**
  3984. * Returns a string representation of this Interval appropriate for debugging.
  3985. * @return {string}
  3986. */
  3987. ;
  3988. _proto.toString = function toString() {
  3989. if (!this.isValid) return INVALID$1;
  3990. return "[" + this.s.toISO() + " \u2013 " + this.e.toISO() + ")";
  3991. }
  3992. /**
  3993. * Returns an ISO 8601-compliant string representation of this Interval.
  3994. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  3995. * @param {Object} opts - The same options as {@link DateTime.toISO}
  3996. * @return {string}
  3997. */
  3998. ;
  3999. _proto.toISO = function toISO(opts) {
  4000. if (!this.isValid) return INVALID$1;
  4001. return this.s.toISO(opts) + "/" + this.e.toISO(opts);
  4002. }
  4003. /**
  4004. * Returns an ISO 8601-compliant string representation of date of this Interval.
  4005. * The time components are ignored.
  4006. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  4007. * @return {string}
  4008. */
  4009. ;
  4010. _proto.toISODate = function toISODate() {
  4011. if (!this.isValid) return INVALID$1;
  4012. return this.s.toISODate() + "/" + this.e.toISODate();
  4013. }
  4014. /**
  4015. * Returns an ISO 8601-compliant string representation of time of this Interval.
  4016. * The date components are ignored.
  4017. * @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
  4018. * @param {Object} opts - The same options as {@link DateTime.toISO}
  4019. * @return {string}
  4020. */
  4021. ;
  4022. _proto.toISOTime = function toISOTime(opts) {
  4023. if (!this.isValid) return INVALID$1;
  4024. return this.s.toISOTime(opts) + "/" + this.e.toISOTime(opts);
  4025. }
  4026. /**
  4027. * Returns a string representation of this Interval formatted according to the specified format string.
  4028. * @param {string} dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details.
  4029. * @param {Object} opts - options
  4030. * @param {string} [opts.separator = ' – '] - a separator to place between the start and end representations
  4031. * @return {string}
  4032. */
  4033. ;
  4034. _proto.toFormat = function toFormat(dateFormat, _temp2) {
  4035. var _ref4 = _temp2 === void 0 ? {} : _temp2,
  4036. _ref4$separator = _ref4.separator,
  4037. separator = _ref4$separator === void 0 ? " – " : _ref4$separator;
  4038. if (!this.isValid) return INVALID$1;
  4039. return "" + this.s.toFormat(dateFormat) + separator + this.e.toFormat(dateFormat);
  4040. }
  4041. /**
  4042. * Return a Duration representing the time spanned by this interval.
  4043. * @param {string|string[]} [unit=['milliseconds']] - the unit or units (such as 'hours' or 'days') to include in the duration.
  4044. * @param {Object} opts - options that affect the creation of the Duration
  4045. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  4046. * @example Interval.fromDateTimes(dt1, dt2).toDuration().toObject() //=> { milliseconds: 88489257 }
  4047. * @example Interval.fromDateTimes(dt1, dt2).toDuration('days').toObject() //=> { days: 1.0241812152777778 }
  4048. * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes']).toObject() //=> { hours: 24, minutes: 34.82095 }
  4049. * @example Interval.fromDateTimes(dt1, dt2).toDuration(['hours', 'minutes', 'seconds']).toObject() //=> { hours: 24, minutes: 34, seconds: 49.257 }
  4050. * @example Interval.fromDateTimes(dt1, dt2).toDuration('seconds').toObject() //=> { seconds: 88489.257 }
  4051. * @return {Duration}
  4052. */
  4053. ;
  4054. _proto.toDuration = function toDuration(unit, opts) {
  4055. if (!this.isValid) {
  4056. return Duration.invalid(this.invalidReason);
  4057. }
  4058. return this.e.diff(this.s, unit, opts);
  4059. }
  4060. /**
  4061. * Run mapFn on the interval start and end, returning a new Interval from the resulting DateTimes
  4062. * @param {function} mapFn
  4063. * @return {Interval}
  4064. * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.toUTC())
  4065. * @example Interval.fromDateTimes(dt1, dt2).mapEndpoints(endpoint => endpoint.plus({ hours: 2 }))
  4066. */
  4067. ;
  4068. _proto.mapEndpoints = function mapEndpoints(mapFn) {
  4069. return Interval.fromDateTimes(mapFn(this.s), mapFn(this.e));
  4070. };
  4071. _createClass(Interval, [{
  4072. key: "start",
  4073. get: function get() {
  4074. return this.isValid ? this.s : null;
  4075. }
  4076. /**
  4077. * Returns the end of the Interval
  4078. * @type {DateTime}
  4079. */
  4080. }, {
  4081. key: "end",
  4082. get: function get() {
  4083. return this.isValid ? this.e : null;
  4084. }
  4085. /**
  4086. * Returns whether this Interval's end is at least its start, meaning that the Interval isn't 'backwards'.
  4087. * @type {boolean}
  4088. */
  4089. }, {
  4090. key: "isValid",
  4091. get: function get() {
  4092. return this.invalidReason === null;
  4093. }
  4094. /**
  4095. * Returns an error code if this Interval is invalid, or null if the Interval is valid
  4096. * @type {string}
  4097. */
  4098. }, {
  4099. key: "invalidReason",
  4100. get: function get() {
  4101. return this.invalid ? this.invalid.reason : null;
  4102. }
  4103. /**
  4104. * Returns an explanation of why this Interval became invalid, or null if the Interval is valid
  4105. * @type {string}
  4106. */
  4107. }, {
  4108. key: "invalidExplanation",
  4109. get: function get() {
  4110. return this.invalid ? this.invalid.explanation : null;
  4111. }
  4112. }]);
  4113. return Interval;
  4114. }();
  4115. /**
  4116. * 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.
  4117. */
  4118. var Info =
  4119. /*#__PURE__*/
  4120. function () {
  4121. function Info() {}
  4122. /**
  4123. * Return whether the specified zone contains a DST.
  4124. * @param {string|Zone} [zone='local'] - Zone to check. Defaults to the environment's local zone.
  4125. * @return {boolean}
  4126. */
  4127. Info.hasDST = function hasDST(zone) {
  4128. if (zone === void 0) {
  4129. zone = Settings.defaultZone;
  4130. }
  4131. var proto = DateTime.local().setZone(zone).set({
  4132. month: 12
  4133. });
  4134. return !zone.universal && proto.offset !== proto.set({
  4135. month: 6
  4136. }).offset;
  4137. }
  4138. /**
  4139. * Return whether the specified zone is a valid IANA specifier.
  4140. * @param {string} zone - Zone to check
  4141. * @return {boolean}
  4142. */
  4143. ;
  4144. Info.isValidIANAZone = function isValidIANAZone(zone) {
  4145. return IANAZone.isValidSpecifier(zone) && IANAZone.isValidZone(zone);
  4146. }
  4147. /**
  4148. * Converts the input into a {@link Zone} instance.
  4149. *
  4150. * * If `input` is already a Zone instance, it is returned unchanged.
  4151. * * If `input` is a string containing a valid time zone name, a Zone instance
  4152. * with that name is returned.
  4153. * * If `input` is a string that doesn't refer to a known time zone, a Zone
  4154. * instance with {@link Zone.isValid} == false is returned.
  4155. * * If `input is a number, a Zone instance with the specified fixed offset
  4156. * in minutes is returned.
  4157. * * If `input` is `null` or `undefined`, the default zone is returned.
  4158. * @param {string|Zone|number} [input] - the value to be converted
  4159. * @return {Zone}
  4160. */
  4161. ;
  4162. Info.normalizeZone = function normalizeZone$1(input) {
  4163. return normalizeZone(input, Settings.defaultZone);
  4164. }
  4165. /**
  4166. * Return an array of standalone month names.
  4167. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  4168. * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
  4169. * @param {Object} opts - options
  4170. * @param {string} [opts.locale] - the locale code
  4171. * @param {string} [opts.numberingSystem=null] - the numbering system
  4172. * @param {string} [opts.outputCalendar='gregory'] - the calendar
  4173. * @example Info.months()[0] //=> 'January'
  4174. * @example Info.months('short')[0] //=> 'Jan'
  4175. * @example Info.months('numeric')[0] //=> '1'
  4176. * @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
  4177. * @example Info.months('numeric', { locale: 'ar' })[0] //=> '١'
  4178. * @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'
  4179. * @return {[string]}
  4180. */
  4181. ;
  4182. Info.months = function months(length, _temp) {
  4183. if (length === void 0) {
  4184. length = "long";
  4185. }
  4186. var _ref = _temp === void 0 ? {} : _temp,
  4187. _ref$locale = _ref.locale,
  4188. locale = _ref$locale === void 0 ? null : _ref$locale,
  4189. _ref$numberingSystem = _ref.numberingSystem,
  4190. numberingSystem = _ref$numberingSystem === void 0 ? null : _ref$numberingSystem,
  4191. _ref$outputCalendar = _ref.outputCalendar,
  4192. outputCalendar = _ref$outputCalendar === void 0 ? "gregory" : _ref$outputCalendar;
  4193. return Locale.create(locale, numberingSystem, outputCalendar).months(length);
  4194. }
  4195. /**
  4196. * Return an array of format month names.
  4197. * Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that
  4198. * changes the string.
  4199. * See {@link months}
  4200. * @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
  4201. * @param {Object} opts - options
  4202. * @param {string} [opts.locale] - the locale code
  4203. * @param {string} [opts.numberingSystem=null] - the numbering system
  4204. * @param {string} [opts.outputCalendar='gregory'] - the calendar
  4205. * @return {[string]}
  4206. */
  4207. ;
  4208. Info.monthsFormat = function monthsFormat(length, _temp2) {
  4209. if (length === void 0) {
  4210. length = "long";
  4211. }
  4212. var _ref2 = _temp2 === void 0 ? {} : _temp2,
  4213. _ref2$locale = _ref2.locale,
  4214. locale = _ref2$locale === void 0 ? null : _ref2$locale,
  4215. _ref2$numberingSystem = _ref2.numberingSystem,
  4216. numberingSystem = _ref2$numberingSystem === void 0 ? null : _ref2$numberingSystem,
  4217. _ref2$outputCalendar = _ref2.outputCalendar,
  4218. outputCalendar = _ref2$outputCalendar === void 0 ? "gregory" : _ref2$outputCalendar;
  4219. return Locale.create(locale, numberingSystem, outputCalendar).months(length, true);
  4220. }
  4221. /**
  4222. * Return an array of standalone week names.
  4223. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  4224. * @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
  4225. * @param {Object} opts - options
  4226. * @param {string} [opts.locale] - the locale code
  4227. * @param {string} [opts.numberingSystem=null] - the numbering system
  4228. * @example Info.weekdays()[0] //=> 'Monday'
  4229. * @example Info.weekdays('short')[0] //=> 'Mon'
  4230. * @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'
  4231. * @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'
  4232. * @return {[string]}
  4233. */
  4234. ;
  4235. Info.weekdays = function weekdays(length, _temp3) {
  4236. if (length === void 0) {
  4237. length = "long";
  4238. }
  4239. var _ref3 = _temp3 === void 0 ? {} : _temp3,
  4240. _ref3$locale = _ref3.locale,
  4241. locale = _ref3$locale === void 0 ? null : _ref3$locale,
  4242. _ref3$numberingSystem = _ref3.numberingSystem,
  4243. numberingSystem = _ref3$numberingSystem === void 0 ? null : _ref3$numberingSystem;
  4244. return Locale.create(locale, numberingSystem, null).weekdays(length);
  4245. }
  4246. /**
  4247. * Return an array of format week names.
  4248. * Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that
  4249. * changes the string.
  4250. * See {@link weekdays}
  4251. * @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
  4252. * @param {Object} opts - options
  4253. * @param {string} [opts.locale=null] - the locale code
  4254. * @param {string} [opts.numberingSystem=null] - the numbering system
  4255. * @return {[string]}
  4256. */
  4257. ;
  4258. Info.weekdaysFormat = function weekdaysFormat(length, _temp4) {
  4259. if (length === void 0) {
  4260. length = "long";
  4261. }
  4262. var _ref4 = _temp4 === void 0 ? {} : _temp4,
  4263. _ref4$locale = _ref4.locale,
  4264. locale = _ref4$locale === void 0 ? null : _ref4$locale,
  4265. _ref4$numberingSystem = _ref4.numberingSystem,
  4266. numberingSystem = _ref4$numberingSystem === void 0 ? null : _ref4$numberingSystem;
  4267. return Locale.create(locale, numberingSystem, null).weekdays(length, true);
  4268. }
  4269. /**
  4270. * Return an array of meridiems.
  4271. * @param {Object} opts - options
  4272. * @param {string} [opts.locale] - the locale code
  4273. * @example Info.meridiems() //=> [ 'AM', 'PM' ]
  4274. * @example Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]
  4275. * @return {[string]}
  4276. */
  4277. ;
  4278. Info.meridiems = function meridiems(_temp5) {
  4279. var _ref5 = _temp5 === void 0 ? {} : _temp5,
  4280. _ref5$locale = _ref5.locale,
  4281. locale = _ref5$locale === void 0 ? null : _ref5$locale;
  4282. return Locale.create(locale).meridiems();
  4283. }
  4284. /**
  4285. * Return an array of eras, such as ['BC', 'AD']. The locale can be specified, but the calendar system is always Gregorian.
  4286. * @param {string} [length='short'] - the length of the era representation, such as "short" or "long".
  4287. * @param {Object} opts - options
  4288. * @param {string} [opts.locale] - the locale code
  4289. * @example Info.eras() //=> [ 'BC', 'AD' ]
  4290. * @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]
  4291. * @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]
  4292. * @return {[string]}
  4293. */
  4294. ;
  4295. Info.eras = function eras(length, _temp6) {
  4296. if (length === void 0) {
  4297. length = "short";
  4298. }
  4299. var _ref6 = _temp6 === void 0 ? {} : _temp6,
  4300. _ref6$locale = _ref6.locale,
  4301. locale = _ref6$locale === void 0 ? null : _ref6$locale;
  4302. return Locale.create(locale, null, "gregory").eras(length);
  4303. }
  4304. /**
  4305. * Return the set of available features in this environment.
  4306. * 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.
  4307. * Keys:
  4308. * * `zones`: whether this environment supports IANA timezones
  4309. * * `intlTokens`: whether this environment supports internationalized token-based formatting/parsing
  4310. * * `intl`: whether this environment supports general internationalization
  4311. * * `relative`: whether this environment supports relative time formatting
  4312. * @example Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false }
  4313. * @return {Object}
  4314. */
  4315. ;
  4316. Info.features = function features() {
  4317. var intl = false,
  4318. intlTokens = false,
  4319. zones = false,
  4320. relative = false;
  4321. if (hasIntl()) {
  4322. intl = true;
  4323. intlTokens = hasFormatToParts();
  4324. relative = hasRelative();
  4325. try {
  4326. zones = new Intl.DateTimeFormat("en", {
  4327. timeZone: "America/New_York"
  4328. }).resolvedOptions().timeZone === "America/New_York";
  4329. } catch (e) {
  4330. zones = false;
  4331. }
  4332. }
  4333. return {
  4334. intl: intl,
  4335. intlTokens: intlTokens,
  4336. zones: zones,
  4337. relative: relative
  4338. };
  4339. };
  4340. return Info;
  4341. }();
  4342. function dayDiff(earlier, later) {
  4343. var utcDayStart = function utcDayStart(dt) {
  4344. return dt.toUTC(0, {
  4345. keepLocalTime: true
  4346. }).startOf("day").valueOf();
  4347. },
  4348. ms = utcDayStart(later) - utcDayStart(earlier);
  4349. return Math.floor(Duration.fromMillis(ms).as("days"));
  4350. }
  4351. function highOrderDiffs(cursor, later, units) {
  4352. var differs = [["years", function (a, b) {
  4353. return b.year - a.year;
  4354. }], ["months", function (a, b) {
  4355. return b.month - a.month + (b.year - a.year) * 12;
  4356. }], ["weeks", function (a, b) {
  4357. var days = dayDiff(a, b);
  4358. return (days - days % 7) / 7;
  4359. }], ["days", dayDiff]];
  4360. var results = {};
  4361. var lowestOrder, highWater;
  4362. for (var _i = 0, _differs = differs; _i < _differs.length; _i++) {
  4363. var _differs$_i = _differs[_i],
  4364. unit = _differs$_i[0],
  4365. differ = _differs$_i[1];
  4366. if (units.indexOf(unit) >= 0) {
  4367. var _cursor$plus;
  4368. lowestOrder = unit;
  4369. var delta = differ(cursor, later);
  4370. highWater = cursor.plus((_cursor$plus = {}, _cursor$plus[unit] = delta, _cursor$plus));
  4371. if (highWater > later) {
  4372. var _cursor$plus2;
  4373. cursor = cursor.plus((_cursor$plus2 = {}, _cursor$plus2[unit] = delta - 1, _cursor$plus2));
  4374. delta -= 1;
  4375. } else {
  4376. cursor = highWater;
  4377. }
  4378. results[unit] = delta;
  4379. }
  4380. }
  4381. return [cursor, results, highWater, lowestOrder];
  4382. }
  4383. function _diff (earlier, later, units, opts) {
  4384. var _highOrderDiffs = highOrderDiffs(earlier, later, units),
  4385. cursor = _highOrderDiffs[0],
  4386. results = _highOrderDiffs[1],
  4387. highWater = _highOrderDiffs[2],
  4388. lowestOrder = _highOrderDiffs[3];
  4389. var remainingMillis = later - cursor;
  4390. var lowerOrderUnits = units.filter(function (u) {
  4391. return ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0;
  4392. });
  4393. if (lowerOrderUnits.length === 0) {
  4394. if (highWater < later) {
  4395. var _cursor$plus3;
  4396. highWater = cursor.plus((_cursor$plus3 = {}, _cursor$plus3[lowestOrder] = 1, _cursor$plus3));
  4397. }
  4398. if (highWater !== cursor) {
  4399. results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor);
  4400. }
  4401. }
  4402. var duration = Duration.fromObject(Object.assign(results, opts));
  4403. if (lowerOrderUnits.length > 0) {
  4404. var _Duration$fromMillis;
  4405. return (_Duration$fromMillis = Duration.fromMillis(remainingMillis, opts)).shiftTo.apply(_Duration$fromMillis, lowerOrderUnits).plus(duration);
  4406. } else {
  4407. return duration;
  4408. }
  4409. }
  4410. var numberingSystems = {
  4411. arab: "[\u0660-\u0669]",
  4412. arabext: "[\u06F0-\u06F9]",
  4413. bali: "[\u1B50-\u1B59]",
  4414. beng: "[\u09E6-\u09EF]",
  4415. deva: "[\u0966-\u096F]",
  4416. fullwide: "[\uFF10-\uFF19]",
  4417. gujr: "[\u0AE6-\u0AEF]",
  4418. hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
  4419. khmr: "[\u17E0-\u17E9]",
  4420. knda: "[\u0CE6-\u0CEF]",
  4421. laoo: "[\u0ED0-\u0ED9]",
  4422. limb: "[\u1946-\u194F]",
  4423. mlym: "[\u0D66-\u0D6F]",
  4424. mong: "[\u1810-\u1819]",
  4425. mymr: "[\u1040-\u1049]",
  4426. orya: "[\u0B66-\u0B6F]",
  4427. tamldec: "[\u0BE6-\u0BEF]",
  4428. telu: "[\u0C66-\u0C6F]",
  4429. thai: "[\u0E50-\u0E59]",
  4430. tibt: "[\u0F20-\u0F29]",
  4431. latn: "\\d"
  4432. };
  4433. var numberingSystemsUTF16 = {
  4434. arab: [1632, 1641],
  4435. arabext: [1776, 1785],
  4436. bali: [6992, 7001],
  4437. beng: [2534, 2543],
  4438. deva: [2406, 2415],
  4439. fullwide: [65296, 65303],
  4440. gujr: [2790, 2799],
  4441. khmr: [6112, 6121],
  4442. knda: [3302, 3311],
  4443. laoo: [3792, 3801],
  4444. limb: [6470, 6479],
  4445. mlym: [3430, 3439],
  4446. mong: [6160, 6169],
  4447. mymr: [4160, 4169],
  4448. orya: [2918, 2927],
  4449. tamldec: [3046, 3055],
  4450. telu: [3174, 3183],
  4451. thai: [3664, 3673],
  4452. tibt: [3872, 3881]
  4453. }; // eslint-disable-next-line
  4454. var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
  4455. function parseDigits(str) {
  4456. var value = parseInt(str, 10);
  4457. if (isNaN(value)) {
  4458. value = "";
  4459. for (var i = 0; i < str.length; i++) {
  4460. var code = str.charCodeAt(i);
  4461. if (str[i].search(numberingSystems.hanidec) !== -1) {
  4462. value += hanidecChars.indexOf(str[i]);
  4463. } else {
  4464. for (var key in numberingSystemsUTF16) {
  4465. var _numberingSystemsUTF = numberingSystemsUTF16[key],
  4466. min = _numberingSystemsUTF[0],
  4467. max = _numberingSystemsUTF[1];
  4468. if (code >= min && code <= max) {
  4469. value += code - min;
  4470. }
  4471. }
  4472. }
  4473. }
  4474. return parseInt(value, 10);
  4475. } else {
  4476. return value;
  4477. }
  4478. }
  4479. function digitRegex(_ref, append) {
  4480. var numberingSystem = _ref.numberingSystem;
  4481. if (append === void 0) {
  4482. append = "";
  4483. }
  4484. return new RegExp("" + numberingSystems[numberingSystem || "latn"] + append);
  4485. }
  4486. var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
  4487. function intUnit(regex, post) {
  4488. if (post === void 0) {
  4489. post = function post(i) {
  4490. return i;
  4491. };
  4492. }
  4493. return {
  4494. regex: regex,
  4495. deser: function deser(_ref) {
  4496. var s = _ref[0];
  4497. return post(parseDigits(s));
  4498. }
  4499. };
  4500. }
  4501. function fixListRegex(s) {
  4502. // make dots optional and also make them literal
  4503. return s.replace(/\./, "\\.?");
  4504. }
  4505. function stripInsensitivities(s) {
  4506. return s.replace(/\./, "").toLowerCase();
  4507. }
  4508. function oneOf(strings, startIndex) {
  4509. if (strings === null) {
  4510. return null;
  4511. } else {
  4512. return {
  4513. regex: RegExp(strings.map(fixListRegex).join("|")),
  4514. deser: function deser(_ref2) {
  4515. var s = _ref2[0];
  4516. return strings.findIndex(function (i) {
  4517. return stripInsensitivities(s) === stripInsensitivities(i);
  4518. }) + startIndex;
  4519. }
  4520. };
  4521. }
  4522. }
  4523. function offset(regex, groups) {
  4524. return {
  4525. regex: regex,
  4526. deser: function deser(_ref3) {
  4527. var h = _ref3[1],
  4528. m = _ref3[2];
  4529. return signedOffset(h, m);
  4530. },
  4531. groups: groups
  4532. };
  4533. }
  4534. function simple(regex) {
  4535. return {
  4536. regex: regex,
  4537. deser: function deser(_ref4) {
  4538. var s = _ref4[0];
  4539. return s;
  4540. }
  4541. };
  4542. }
  4543. function escapeToken(value) {
  4544. // eslint-disable-next-line no-useless-escape
  4545. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  4546. }
  4547. function unitForToken(token, loc) {
  4548. var one = digitRegex(loc),
  4549. two = digitRegex(loc, "{2}"),
  4550. three = digitRegex(loc, "{3}"),
  4551. four = digitRegex(loc, "{4}"),
  4552. six = digitRegex(loc, "{6}"),
  4553. oneOrTwo = digitRegex(loc, "{1,2}"),
  4554. oneToThree = digitRegex(loc, "{1,3}"),
  4555. oneToSix = digitRegex(loc, "{1,6}"),
  4556. oneToNine = digitRegex(loc, "{1,9}"),
  4557. twoToFour = digitRegex(loc, "{2,4}"),
  4558. fourToSix = digitRegex(loc, "{4,6}"),
  4559. literal = function literal(t) {
  4560. return {
  4561. regex: RegExp(escapeToken(t.val)),
  4562. deser: function deser(_ref5) {
  4563. var s = _ref5[0];
  4564. return s;
  4565. },
  4566. literal: true
  4567. };
  4568. },
  4569. unitate = function unitate(t) {
  4570. if (token.literal) {
  4571. return literal(t);
  4572. }
  4573. switch (t.val) {
  4574. // era
  4575. case "G":
  4576. return oneOf(loc.eras("short", false), 0);
  4577. case "GG":
  4578. return oneOf(loc.eras("long", false), 0);
  4579. // years
  4580. case "y":
  4581. return intUnit(oneToSix);
  4582. case "yy":
  4583. return intUnit(twoToFour, untruncateYear);
  4584. case "yyyy":
  4585. return intUnit(four);
  4586. case "yyyyy":
  4587. return intUnit(fourToSix);
  4588. case "yyyyyy":
  4589. return intUnit(six);
  4590. // months
  4591. case "M":
  4592. return intUnit(oneOrTwo);
  4593. case "MM":
  4594. return intUnit(two);
  4595. case "MMM":
  4596. return oneOf(loc.months("short", true, false), 1);
  4597. case "MMMM":
  4598. return oneOf(loc.months("long", true, false), 1);
  4599. case "L":
  4600. return intUnit(oneOrTwo);
  4601. case "LL":
  4602. return intUnit(two);
  4603. case "LLL":
  4604. return oneOf(loc.months("short", false, false), 1);
  4605. case "LLLL":
  4606. return oneOf(loc.months("long", false, false), 1);
  4607. // dates
  4608. case "d":
  4609. return intUnit(oneOrTwo);
  4610. case "dd":
  4611. return intUnit(two);
  4612. // ordinals
  4613. case "o":
  4614. return intUnit(oneToThree);
  4615. case "ooo":
  4616. return intUnit(three);
  4617. // time
  4618. case "HH":
  4619. return intUnit(two);
  4620. case "H":
  4621. return intUnit(oneOrTwo);
  4622. case "hh":
  4623. return intUnit(two);
  4624. case "h":
  4625. return intUnit(oneOrTwo);
  4626. case "mm":
  4627. return intUnit(two);
  4628. case "m":
  4629. return intUnit(oneOrTwo);
  4630. case "q":
  4631. return intUnit(oneOrTwo);
  4632. case "qq":
  4633. return intUnit(two);
  4634. case "s":
  4635. return intUnit(oneOrTwo);
  4636. case "ss":
  4637. return intUnit(two);
  4638. case "S":
  4639. return intUnit(oneToThree);
  4640. case "SSS":
  4641. return intUnit(three);
  4642. case "u":
  4643. return simple(oneToNine);
  4644. // meridiem
  4645. case "a":
  4646. return oneOf(loc.meridiems(), 0);
  4647. // weekYear (k)
  4648. case "kkkk":
  4649. return intUnit(four);
  4650. case "kk":
  4651. return intUnit(twoToFour, untruncateYear);
  4652. // weekNumber (W)
  4653. case "W":
  4654. return intUnit(oneOrTwo);
  4655. case "WW":
  4656. return intUnit(two);
  4657. // weekdays
  4658. case "E":
  4659. case "c":
  4660. return intUnit(one);
  4661. case "EEE":
  4662. return oneOf(loc.weekdays("short", false, false), 1);
  4663. case "EEEE":
  4664. return oneOf(loc.weekdays("long", false, false), 1);
  4665. case "ccc":
  4666. return oneOf(loc.weekdays("short", true, false), 1);
  4667. case "cccc":
  4668. return oneOf(loc.weekdays("long", true, false), 1);
  4669. // offset/zone
  4670. case "Z":
  4671. case "ZZ":
  4672. return offset(new RegExp("([+-]" + oneOrTwo.source + ")(?::(" + two.source + "))?"), 2);
  4673. case "ZZZ":
  4674. return offset(new RegExp("([+-]" + oneOrTwo.source + ")(" + two.source + ")?"), 2);
  4675. // we don't support ZZZZ (PST) or ZZZZZ (Pacific Standard Time) in parsing
  4676. // because we don't have any way to figure out what they are
  4677. case "z":
  4678. return simple(/[a-z_+-/]{1,256}?/i);
  4679. default:
  4680. return literal(t);
  4681. }
  4682. };
  4683. var unit = unitate(token) || {
  4684. invalidReason: MISSING_FTP
  4685. };
  4686. unit.token = token;
  4687. return unit;
  4688. }
  4689. var partTypeStyleToTokenVal = {
  4690. year: {
  4691. "2-digit": "yy",
  4692. numeric: "yyyyy"
  4693. },
  4694. month: {
  4695. numeric: "M",
  4696. "2-digit": "MM",
  4697. short: "MMM",
  4698. long: "MMMM"
  4699. },
  4700. day: {
  4701. numeric: "d",
  4702. "2-digit": "dd"
  4703. },
  4704. weekday: {
  4705. short: "EEE",
  4706. long: "EEEE"
  4707. },
  4708. dayperiod: "a",
  4709. dayPeriod: "a",
  4710. hour: {
  4711. numeric: "h",
  4712. "2-digit": "hh"
  4713. },
  4714. minute: {
  4715. numeric: "m",
  4716. "2-digit": "mm"
  4717. },
  4718. second: {
  4719. numeric: "s",
  4720. "2-digit": "ss"
  4721. }
  4722. };
  4723. function tokenForPart(part, locale, formatOpts) {
  4724. var type = part.type,
  4725. value = part.value;
  4726. if (type === "literal") {
  4727. return {
  4728. literal: true,
  4729. val: value
  4730. };
  4731. }
  4732. var style = formatOpts[type];
  4733. var val = partTypeStyleToTokenVal[type];
  4734. if (typeof val === "object") {
  4735. val = val[style];
  4736. }
  4737. if (val) {
  4738. return {
  4739. literal: false,
  4740. val: val
  4741. };
  4742. }
  4743. return undefined;
  4744. }
  4745. function buildRegex(units) {
  4746. var re = units.map(function (u) {
  4747. return u.regex;
  4748. }).reduce(function (f, r) {
  4749. return f + "(" + r.source + ")";
  4750. }, "");
  4751. return ["^" + re + "$", units];
  4752. }
  4753. function match(input, regex, handlers) {
  4754. var matches = input.match(regex);
  4755. if (matches) {
  4756. var all = {};
  4757. var matchIndex = 1;
  4758. for (var i in handlers) {
  4759. if (hasOwnProperty(handlers, i)) {
  4760. var h = handlers[i],
  4761. groups = h.groups ? h.groups + 1 : 1;
  4762. if (!h.literal && h.token) {
  4763. all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
  4764. }
  4765. matchIndex += groups;
  4766. }
  4767. }
  4768. return [matches, all];
  4769. } else {
  4770. return [matches, {}];
  4771. }
  4772. }
  4773. function dateTimeFromMatches(matches) {
  4774. var toField = function toField(token) {
  4775. switch (token) {
  4776. case "S":
  4777. return "millisecond";
  4778. case "s":
  4779. return "second";
  4780. case "m":
  4781. return "minute";
  4782. case "h":
  4783. case "H":
  4784. return "hour";
  4785. case "d":
  4786. return "day";
  4787. case "o":
  4788. return "ordinal";
  4789. case "L":
  4790. case "M":
  4791. return "month";
  4792. case "y":
  4793. return "year";
  4794. case "E":
  4795. case "c":
  4796. return "weekday";
  4797. case "W":
  4798. return "weekNumber";
  4799. case "k":
  4800. return "weekYear";
  4801. case "q":
  4802. return "quarter";
  4803. default:
  4804. return null;
  4805. }
  4806. };
  4807. var zone;
  4808. if (!isUndefined(matches.Z)) {
  4809. zone = new FixedOffsetZone(matches.Z);
  4810. } else if (!isUndefined(matches.z)) {
  4811. zone = IANAZone.create(matches.z);
  4812. } else {
  4813. zone = null;
  4814. }
  4815. if (!isUndefined(matches.q)) {
  4816. matches.M = (matches.q - 1) * 3 + 1;
  4817. }
  4818. if (!isUndefined(matches.h)) {
  4819. if (matches.h < 12 && matches.a === 1) {
  4820. matches.h += 12;
  4821. } else if (matches.h === 12 && matches.a === 0) {
  4822. matches.h = 0;
  4823. }
  4824. }
  4825. if (matches.G === 0 && matches.y) {
  4826. matches.y = -matches.y;
  4827. }
  4828. if (!isUndefined(matches.u)) {
  4829. matches.S = parseMillis(matches.u);
  4830. }
  4831. var vals = Object.keys(matches).reduce(function (r, k) {
  4832. var f = toField(k);
  4833. if (f) {
  4834. r[f] = matches[k];
  4835. }
  4836. return r;
  4837. }, {});
  4838. return [vals, zone];
  4839. }
  4840. var dummyDateTimeCache = null;
  4841. function getDummyDateTime() {
  4842. if (!dummyDateTimeCache) {
  4843. dummyDateTimeCache = DateTime.fromMillis(1555555555555);
  4844. }
  4845. return dummyDateTimeCache;
  4846. }
  4847. function maybeExpandMacroToken(token, locale) {
  4848. if (token.literal) {
  4849. return token;
  4850. }
  4851. var formatOpts = Formatter.macroTokenToFormatOpts(token.val);
  4852. if (!formatOpts) {
  4853. return token;
  4854. }
  4855. var formatter = Formatter.create(locale, formatOpts);
  4856. var parts = formatter.formatDateTimeParts(getDummyDateTime());
  4857. var tokens = parts.map(function (p) {
  4858. return tokenForPart(p, locale, formatOpts);
  4859. });
  4860. if (tokens.includes(undefined)) {
  4861. return token;
  4862. }
  4863. return tokens;
  4864. }
  4865. function expandMacroTokens(tokens, locale) {
  4866. var _Array$prototype;
  4867. return (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, tokens.map(function (t) {
  4868. return maybeExpandMacroToken(t, locale);
  4869. }));
  4870. }
  4871. /**
  4872. * @private
  4873. */
  4874. function explainFromTokens(locale, input, format) {
  4875. var tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
  4876. units = tokens.map(function (t) {
  4877. return unitForToken(t, locale);
  4878. }),
  4879. disqualifyingUnit = units.find(function (t) {
  4880. return t.invalidReason;
  4881. });
  4882. if (disqualifyingUnit) {
  4883. return {
  4884. input: input,
  4885. tokens: tokens,
  4886. invalidReason: disqualifyingUnit.invalidReason
  4887. };
  4888. } else {
  4889. var _buildRegex = buildRegex(units),
  4890. regexString = _buildRegex[0],
  4891. handlers = _buildRegex[1],
  4892. regex = RegExp(regexString, "i"),
  4893. _match = match(input, regex, handlers),
  4894. rawMatches = _match[0],
  4895. matches = _match[1],
  4896. _ref6 = matches ? dateTimeFromMatches(matches) : [null, null],
  4897. result = _ref6[0],
  4898. zone = _ref6[1];
  4899. return {
  4900. input: input,
  4901. tokens: tokens,
  4902. regex: regex,
  4903. rawMatches: rawMatches,
  4904. matches: matches,
  4905. result: result,
  4906. zone: zone
  4907. };
  4908. }
  4909. }
  4910. function parseFromTokens(locale, input, format) {
  4911. var _explainFromTokens = explainFromTokens(locale, input, format),
  4912. result = _explainFromTokens.result,
  4913. zone = _explainFromTokens.zone,
  4914. invalidReason = _explainFromTokens.invalidReason;
  4915. return [result, zone, invalidReason];
  4916. }
  4917. var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
  4918. leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
  4919. function unitOutOfRange(unit, value) {
  4920. return new Invalid("unit out of range", "you specified " + value + " (of type " + typeof value + ") as a " + unit + ", which is invalid");
  4921. }
  4922. function dayOfWeek(year, month, day) {
  4923. var js = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
  4924. return js === 0 ? 7 : js;
  4925. }
  4926. function computeOrdinal(year, month, day) {
  4927. return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1];
  4928. }
  4929. function uncomputeOrdinal(year, ordinal) {
  4930. var table = isLeapYear(year) ? leapLadder : nonLeapLadder,
  4931. month0 = table.findIndex(function (i) {
  4932. return i < ordinal;
  4933. }),
  4934. day = ordinal - table[month0];
  4935. return {
  4936. month: month0 + 1,
  4937. day: day
  4938. };
  4939. }
  4940. /**
  4941. * @private
  4942. */
  4943. function gregorianToWeek(gregObj) {
  4944. var year = gregObj.year,
  4945. month = gregObj.month,
  4946. day = gregObj.day,
  4947. ordinal = computeOrdinal(year, month, day),
  4948. weekday = dayOfWeek(year, month, day);
  4949. var weekNumber = Math.floor((ordinal - weekday + 10) / 7),
  4950. weekYear;
  4951. if (weekNumber < 1) {
  4952. weekYear = year - 1;
  4953. weekNumber = weeksInWeekYear(weekYear);
  4954. } else if (weekNumber > weeksInWeekYear(year)) {
  4955. weekYear = year + 1;
  4956. weekNumber = 1;
  4957. } else {
  4958. weekYear = year;
  4959. }
  4960. return Object.assign({
  4961. weekYear: weekYear,
  4962. weekNumber: weekNumber,
  4963. weekday: weekday
  4964. }, timeObject(gregObj));
  4965. }
  4966. function weekToGregorian(weekData) {
  4967. var weekYear = weekData.weekYear,
  4968. weekNumber = weekData.weekNumber,
  4969. weekday = weekData.weekday,
  4970. weekdayOfJan4 = dayOfWeek(weekYear, 1, 4),
  4971. yearInDays = daysInYear(weekYear);
  4972. var ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3,
  4973. year;
  4974. if (ordinal < 1) {
  4975. year = weekYear - 1;
  4976. ordinal += daysInYear(year);
  4977. } else if (ordinal > yearInDays) {
  4978. year = weekYear + 1;
  4979. ordinal -= daysInYear(weekYear);
  4980. } else {
  4981. year = weekYear;
  4982. }
  4983. var _uncomputeOrdinal = uncomputeOrdinal(year, ordinal),
  4984. month = _uncomputeOrdinal.month,
  4985. day = _uncomputeOrdinal.day;
  4986. return Object.assign({
  4987. year: year,
  4988. month: month,
  4989. day: day
  4990. }, timeObject(weekData));
  4991. }
  4992. function gregorianToOrdinal(gregData) {
  4993. var year = gregData.year,
  4994. month = gregData.month,
  4995. day = gregData.day,
  4996. ordinal = computeOrdinal(year, month, day);
  4997. return Object.assign({
  4998. year: year,
  4999. ordinal: ordinal
  5000. }, timeObject(gregData));
  5001. }
  5002. function ordinalToGregorian(ordinalData) {
  5003. var year = ordinalData.year,
  5004. ordinal = ordinalData.ordinal,
  5005. _uncomputeOrdinal2 = uncomputeOrdinal(year, ordinal),
  5006. month = _uncomputeOrdinal2.month,
  5007. day = _uncomputeOrdinal2.day;
  5008. return Object.assign({
  5009. year: year,
  5010. month: month,
  5011. day: day
  5012. }, timeObject(ordinalData));
  5013. }
  5014. function hasInvalidWeekData(obj) {
  5015. var validYear = isInteger(obj.weekYear),
  5016. validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)),
  5017. validWeekday = integerBetween(obj.weekday, 1, 7);
  5018. if (!validYear) {
  5019. return unitOutOfRange("weekYear", obj.weekYear);
  5020. } else if (!validWeek) {
  5021. return unitOutOfRange("week", obj.week);
  5022. } else if (!validWeekday) {
  5023. return unitOutOfRange("weekday", obj.weekday);
  5024. } else return false;
  5025. }
  5026. function hasInvalidOrdinalData(obj) {
  5027. var validYear = isInteger(obj.year),
  5028. validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year));
  5029. if (!validYear) {
  5030. return unitOutOfRange("year", obj.year);
  5031. } else if (!validOrdinal) {
  5032. return unitOutOfRange("ordinal", obj.ordinal);
  5033. } else return false;
  5034. }
  5035. function hasInvalidGregorianData(obj) {
  5036. var validYear = isInteger(obj.year),
  5037. validMonth = integerBetween(obj.month, 1, 12),
  5038. validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month));
  5039. if (!validYear) {
  5040. return unitOutOfRange("year", obj.year);
  5041. } else if (!validMonth) {
  5042. return unitOutOfRange("month", obj.month);
  5043. } else if (!validDay) {
  5044. return unitOutOfRange("day", obj.day);
  5045. } else return false;
  5046. }
  5047. function hasInvalidTimeData(obj) {
  5048. var hour = obj.hour,
  5049. minute = obj.minute,
  5050. second = obj.second,
  5051. millisecond = obj.millisecond;
  5052. var validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0,
  5053. validMinute = integerBetween(minute, 0, 59),
  5054. validSecond = integerBetween(second, 0, 59),
  5055. validMillisecond = integerBetween(millisecond, 0, 999);
  5056. if (!validHour) {
  5057. return unitOutOfRange("hour", hour);
  5058. } else if (!validMinute) {
  5059. return unitOutOfRange("minute", minute);
  5060. } else if (!validSecond) {
  5061. return unitOutOfRange("second", second);
  5062. } else if (!validMillisecond) {
  5063. return unitOutOfRange("millisecond", millisecond);
  5064. } else return false;
  5065. }
  5066. var INVALID$2 = "Invalid DateTime";
  5067. var MAX_DATE = 8.64e15;
  5068. function unsupportedZone(zone) {
  5069. return new Invalid("unsupported zone", "the zone \"" + zone.name + "\" is not supported");
  5070. } // we cache week data on the DT object and this intermediates the cache
  5071. function possiblyCachedWeekData(dt) {
  5072. if (dt.weekData === null) {
  5073. dt.weekData = gregorianToWeek(dt.c);
  5074. }
  5075. return dt.weekData;
  5076. } // clone really means, "make a new object with these modifications". all "setters" really use this
  5077. // to create a new object while only changing some of the properties
  5078. function clone$1(inst, alts) {
  5079. var current = {
  5080. ts: inst.ts,
  5081. zone: inst.zone,
  5082. c: inst.c,
  5083. o: inst.o,
  5084. loc: inst.loc,
  5085. invalid: inst.invalid
  5086. };
  5087. return new DateTime(Object.assign({}, current, alts, {
  5088. old: current
  5089. }));
  5090. } // find the right offset a given local time. The o input is our guess, which determines which
  5091. // offset we'll pick in ambiguous cases (e.g. there are two 3 AMs b/c Fallback DST)
  5092. function fixOffset(localTS, o, tz) {
  5093. // Our UTC time is just a guess because our offset is just a guess
  5094. var utcGuess = localTS - o * 60 * 1000; // Test whether the zone matches the offset for this ts
  5095. var o2 = tz.offset(utcGuess); // If so, offset didn't change and we're done
  5096. if (o === o2) {
  5097. return [utcGuess, o];
  5098. } // If not, change the ts by the difference in the offset
  5099. utcGuess -= (o2 - o) * 60 * 1000; // If that gives us the local time we want, we're done
  5100. var o3 = tz.offset(utcGuess);
  5101. if (o2 === o3) {
  5102. return [utcGuess, o2];
  5103. } // If it's different, we're in a hole time. The offset has changed, but the we don't adjust the time
  5104. return [localTS - Math.min(o2, o3) * 60 * 1000, Math.max(o2, o3)];
  5105. } // convert an epoch timestamp into a calendar object with the given offset
  5106. function tsToObj(ts, offset) {
  5107. ts += offset * 60 * 1000;
  5108. var d = new Date(ts);
  5109. return {
  5110. year: d.getUTCFullYear(),
  5111. month: d.getUTCMonth() + 1,
  5112. day: d.getUTCDate(),
  5113. hour: d.getUTCHours(),
  5114. minute: d.getUTCMinutes(),
  5115. second: d.getUTCSeconds(),
  5116. millisecond: d.getUTCMilliseconds()
  5117. };
  5118. } // convert a calendar object to a epoch timestamp
  5119. function objToTS(obj, offset, zone) {
  5120. return fixOffset(objToLocalTS(obj), offset, zone);
  5121. } // create a new DT instance by adding a duration, adjusting for DSTs
  5122. function adjustTime(inst, dur) {
  5123. var _dur;
  5124. var keys = Object.keys(dur.values);
  5125. if (keys.indexOf("milliseconds") === -1) {
  5126. keys.push("milliseconds");
  5127. }
  5128. dur = (_dur = dur).shiftTo.apply(_dur, keys);
  5129. var oPre = inst.o,
  5130. year = inst.c.year + dur.years,
  5131. month = inst.c.month + dur.months + dur.quarters * 3,
  5132. c = Object.assign({}, inst.c, {
  5133. year: year,
  5134. month: month,
  5135. day: Math.min(inst.c.day, daysInMonth(year, month)) + dur.days + dur.weeks * 7
  5136. }),
  5137. millisToAdd = Duration.fromObject({
  5138. hours: dur.hours,
  5139. minutes: dur.minutes,
  5140. seconds: dur.seconds,
  5141. milliseconds: dur.milliseconds
  5142. }).as("milliseconds"),
  5143. localTS = objToLocalTS(c);
  5144. var _fixOffset = fixOffset(localTS, oPre, inst.zone),
  5145. ts = _fixOffset[0],
  5146. o = _fixOffset[1];
  5147. if (millisToAdd !== 0) {
  5148. ts += millisToAdd; // that could have changed the offset by going over a DST, but we want to keep the ts the same
  5149. o = inst.zone.offset(ts);
  5150. }
  5151. return {
  5152. ts: ts,
  5153. o: o
  5154. };
  5155. } // helper useful in turning the results of parsing into real dates
  5156. // by handling the zone options
  5157. function parseDataToDateTime(parsed, parsedZone, opts, format, text) {
  5158. var setZone = opts.setZone,
  5159. zone = opts.zone;
  5160. if (parsed && Object.keys(parsed).length !== 0) {
  5161. var interpretationZone = parsedZone || zone,
  5162. inst = DateTime.fromObject(Object.assign(parsed, opts, {
  5163. zone: interpretationZone,
  5164. // setZone is a valid option in the calling methods, but not in fromObject
  5165. setZone: undefined
  5166. }));
  5167. return setZone ? inst : inst.setZone(zone);
  5168. } else {
  5169. return DateTime.invalid(new Invalid("unparsable", "the input \"" + text + "\" can't be parsed as " + format));
  5170. }
  5171. } // if you want to output a technical format (e.g. RFC 2822), this helper
  5172. // helps handle the details
  5173. function toTechFormat(dt, format) {
  5174. return dt.isValid ? Formatter.create(Locale.create("en-US"), {
  5175. allowZ: true,
  5176. forceSimple: true
  5177. }).formatDateTimeFromString(dt, format) : null;
  5178. } // technical time formats (e.g. the time part of ISO 8601), take some options
  5179. // and this commonizes their handling
  5180. function toTechTimeFormat(dt, _ref) {
  5181. var _ref$suppressSeconds = _ref.suppressSeconds,
  5182. suppressSeconds = _ref$suppressSeconds === void 0 ? false : _ref$suppressSeconds,
  5183. _ref$suppressMillisec = _ref.suppressMilliseconds,
  5184. suppressMilliseconds = _ref$suppressMillisec === void 0 ? false : _ref$suppressMillisec,
  5185. includeOffset = _ref.includeOffset,
  5186. _ref$includeZone = _ref.includeZone,
  5187. includeZone = _ref$includeZone === void 0 ? false : _ref$includeZone,
  5188. _ref$spaceZone = _ref.spaceZone,
  5189. spaceZone = _ref$spaceZone === void 0 ? false : _ref$spaceZone;
  5190. var fmt = "HH:mm";
  5191. if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
  5192. fmt += ":ss";
  5193. if (!suppressMilliseconds || dt.millisecond !== 0) {
  5194. fmt += ".SSS";
  5195. }
  5196. }
  5197. if ((includeZone || includeOffset) && spaceZone) {
  5198. fmt += " ";
  5199. }
  5200. if (includeZone) {
  5201. fmt += "z";
  5202. } else if (includeOffset) {
  5203. fmt += "ZZ";
  5204. }
  5205. return toTechFormat(dt, fmt);
  5206. } // defaults for unspecified units in the supported calendars
  5207. var defaultUnitValues = {
  5208. month: 1,
  5209. day: 1,
  5210. hour: 0,
  5211. minute: 0,
  5212. second: 0,
  5213. millisecond: 0
  5214. },
  5215. defaultWeekUnitValues = {
  5216. weekNumber: 1,
  5217. weekday: 1,
  5218. hour: 0,
  5219. minute: 0,
  5220. second: 0,
  5221. millisecond: 0
  5222. },
  5223. defaultOrdinalUnitValues = {
  5224. ordinal: 1,
  5225. hour: 0,
  5226. minute: 0,
  5227. second: 0,
  5228. millisecond: 0
  5229. }; // Units in the supported calendars, sorted by bigness
  5230. var orderedUnits$1 = ["year", "month", "day", "hour", "minute", "second", "millisecond"],
  5231. orderedWeekUnits = ["weekYear", "weekNumber", "weekday", "hour", "minute", "second", "millisecond"],
  5232. orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"]; // standardize case and plurality in units
  5233. function normalizeUnit(unit) {
  5234. var normalized = {
  5235. year: "year",
  5236. years: "year",
  5237. month: "month",
  5238. months: "month",
  5239. day: "day",
  5240. days: "day",
  5241. hour: "hour",
  5242. hours: "hour",
  5243. minute: "minute",
  5244. minutes: "minute",
  5245. quarter: "quarter",
  5246. quarters: "quarter",
  5247. second: "second",
  5248. seconds: "second",
  5249. millisecond: "millisecond",
  5250. milliseconds: "millisecond",
  5251. weekday: "weekday",
  5252. weekdays: "weekday",
  5253. weeknumber: "weekNumber",
  5254. weeksnumber: "weekNumber",
  5255. weeknumbers: "weekNumber",
  5256. weekyear: "weekYear",
  5257. weekyears: "weekYear",
  5258. ordinal: "ordinal"
  5259. }[unit.toLowerCase()];
  5260. if (!normalized) throw new InvalidUnitError(unit);
  5261. return normalized;
  5262. } // this is a dumbed down version of fromObject() that runs about 60% faster
  5263. // but doesn't do any validation, makes a bunch of assumptions about what units
  5264. // are present, and so on.
  5265. function quickDT(obj, zone) {
  5266. // assume we have the higher-order units
  5267. for (var _i = 0, _orderedUnits = orderedUnits$1; _i < _orderedUnits.length; _i++) {
  5268. var u = _orderedUnits[_i];
  5269. if (isUndefined(obj[u])) {
  5270. obj[u] = defaultUnitValues[u];
  5271. }
  5272. }
  5273. var invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
  5274. if (invalid) {
  5275. return DateTime.invalid(invalid);
  5276. }
  5277. var tsNow = Settings.now(),
  5278. offsetProvis = zone.offset(tsNow),
  5279. _objToTS = objToTS(obj, offsetProvis, zone),
  5280. ts = _objToTS[0],
  5281. o = _objToTS[1];
  5282. return new DateTime({
  5283. ts: ts,
  5284. zone: zone,
  5285. o: o
  5286. });
  5287. }
  5288. function diffRelative(start, end, opts) {
  5289. var round = isUndefined(opts.round) ? true : opts.round,
  5290. format = function format(c, unit) {
  5291. c = roundTo(c, round || opts.calendary ? 0 : 2, true);
  5292. var formatter = end.loc.clone(opts).relFormatter(opts);
  5293. return formatter.format(c, unit);
  5294. },
  5295. differ = function differ(unit) {
  5296. if (opts.calendary) {
  5297. if (!end.hasSame(start, unit)) {
  5298. return end.startOf(unit).diff(start.startOf(unit), unit).get(unit);
  5299. } else return 0;
  5300. } else {
  5301. return end.diff(start, unit).get(unit);
  5302. }
  5303. };
  5304. if (opts.unit) {
  5305. return format(differ(opts.unit), opts.unit);
  5306. }
  5307. for (var _iterator = opts.units, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
  5308. var _ref2;
  5309. if (_isArray) {
  5310. if (_i2 >= _iterator.length) break;
  5311. _ref2 = _iterator[_i2++];
  5312. } else {
  5313. _i2 = _iterator.next();
  5314. if (_i2.done) break;
  5315. _ref2 = _i2.value;
  5316. }
  5317. var unit = _ref2;
  5318. var count = differ(unit);
  5319. if (Math.abs(count) >= 1) {
  5320. return format(count, unit);
  5321. }
  5322. }
  5323. return format(0, opts.units[opts.units.length - 1]);
  5324. }
  5325. /**
  5326. * 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.
  5327. *
  5328. * A DateTime comprises of:
  5329. * * A timestamp. Each DateTime instance refers to a specific millisecond of the Unix epoch.
  5330. * * A time zone. Each instance is considered in the context of a specific zone (by default the local system's zone).
  5331. * * Configuration properties that effect how output strings are formatted, such as `locale`, `numberingSystem`, and `outputCalendar`.
  5332. *
  5333. * Here is a brief overview of the most commonly used functionality it provides:
  5334. *
  5335. * * **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}.
  5336. * * **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},
  5337. * {@link day}, {@link hour}, {@link minute}, {@link second}, {@link millisecond} accessors.
  5338. * * **Week calendar**: For ISO week calendar attributes, see the {@link weekYear}, {@link weekNumber}, and {@link weekday} accessors.
  5339. * * **Configuration** See the {@link locale} and {@link numberingSystem} accessors.
  5340. * * **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}.
  5341. * * **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}.
  5342. *
  5343. * 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.
  5344. */
  5345. var DateTime =
  5346. /*#__PURE__*/
  5347. function () {
  5348. /**
  5349. * @access private
  5350. */
  5351. function DateTime(config) {
  5352. var zone = config.zone || Settings.defaultZone;
  5353. var invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
  5354. /**
  5355. * @access private
  5356. */
  5357. this.ts = isUndefined(config.ts) ? Settings.now() : config.ts;
  5358. var c = null,
  5359. o = null;
  5360. if (!invalid) {
  5361. var unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
  5362. if (unchanged) {
  5363. var _ref3 = [config.old.c, config.old.o];
  5364. c = _ref3[0];
  5365. o = _ref3[1];
  5366. } else {
  5367. c = tsToObj(this.ts, zone.offset(this.ts));
  5368. invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
  5369. c = invalid ? null : c;
  5370. o = invalid ? null : zone.offset(this.ts);
  5371. }
  5372. }
  5373. /**
  5374. * @access private
  5375. */
  5376. this._zone = zone;
  5377. /**
  5378. * @access private
  5379. */
  5380. this.loc = config.loc || Locale.create();
  5381. /**
  5382. * @access private
  5383. */
  5384. this.invalid = invalid;
  5385. /**
  5386. * @access private
  5387. */
  5388. this.weekData = null;
  5389. /**
  5390. * @access private
  5391. */
  5392. this.c = c;
  5393. /**
  5394. * @access private
  5395. */
  5396. this.o = o;
  5397. /**
  5398. * @access private
  5399. */
  5400. this.isLuxonDateTime = true;
  5401. } // CONSTRUCT
  5402. /**
  5403. * Create a local DateTime
  5404. * @param {number} [year] - The calendar year. If omitted (as in, call `local()` with no arguments), the current time will be used
  5405. * @param {number} [month=1] - The month, 1-indexed
  5406. * @param {number} [day=1] - The day of the month
  5407. * @param {number} [hour=0] - The hour of the day, in 24-hour time
  5408. * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
  5409. * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
  5410. * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
  5411. * @example DateTime.local() //~> now
  5412. * @example DateTime.local(2017) //~> 2017-01-01T00:00:00
  5413. * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
  5414. * @example DateTime.local(2017, 3, 12) //~> 2017-03-12T00:00:00
  5415. * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
  5416. * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
  5417. * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
  5418. * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
  5419. * @return {DateTime}
  5420. */
  5421. DateTime.local = function local(year, month, day, hour, minute, second, millisecond) {
  5422. if (isUndefined(year)) {
  5423. return new DateTime({
  5424. ts: Settings.now()
  5425. });
  5426. } else {
  5427. return quickDT({
  5428. year: year,
  5429. month: month,
  5430. day: day,
  5431. hour: hour,
  5432. minute: minute,
  5433. second: second,
  5434. millisecond: millisecond
  5435. }, Settings.defaultZone);
  5436. }
  5437. }
  5438. /**
  5439. * Create a DateTime in UTC
  5440. * @param {number} [year] - The calendar year. If omitted (as in, call `utc()` with no arguments), the current time will be used
  5441. * @param {number} [month=1] - The month, 1-indexed
  5442. * @param {number} [day=1] - The day of the month
  5443. * @param {number} [hour=0] - The hour of the day, in 24-hour time
  5444. * @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
  5445. * @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
  5446. * @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
  5447. * @example DateTime.utc() //~> now
  5448. * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
  5449. * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
  5450. * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
  5451. * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
  5452. * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
  5453. * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
  5454. * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765Z
  5455. * @return {DateTime}
  5456. */
  5457. ;
  5458. DateTime.utc = function utc(year, month, day, hour, minute, second, millisecond) {
  5459. if (isUndefined(year)) {
  5460. return new DateTime({
  5461. ts: Settings.now(),
  5462. zone: FixedOffsetZone.utcInstance
  5463. });
  5464. } else {
  5465. return quickDT({
  5466. year: year,
  5467. month: month,
  5468. day: day,
  5469. hour: hour,
  5470. minute: minute,
  5471. second: second,
  5472. millisecond: millisecond
  5473. }, FixedOffsetZone.utcInstance);
  5474. }
  5475. }
  5476. /**
  5477. * Create a DateTime from a Javascript Date object. Uses the default zone.
  5478. * @param {Date} date - a Javascript Date object
  5479. * @param {Object} options - configuration options for the DateTime
  5480. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5481. * @return {DateTime}
  5482. */
  5483. ;
  5484. DateTime.fromJSDate = function fromJSDate(date, options) {
  5485. if (options === void 0) {
  5486. options = {};
  5487. }
  5488. var ts = isDate(date) ? date.valueOf() : NaN;
  5489. if (Number.isNaN(ts)) {
  5490. return DateTime.invalid("invalid input");
  5491. }
  5492. var zoneToUse = normalizeZone(options.zone, Settings.defaultZone);
  5493. if (!zoneToUse.isValid) {
  5494. return DateTime.invalid(unsupportedZone(zoneToUse));
  5495. }
  5496. return new DateTime({
  5497. ts: ts,
  5498. zone: zoneToUse,
  5499. loc: Locale.fromObject(options)
  5500. });
  5501. }
  5502. /**
  5503. * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
  5504. * @param {number} milliseconds - a number of milliseconds since 1970 UTC
  5505. * @param {Object} options - configuration options for the DateTime
  5506. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5507. * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
  5508. * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
  5509. * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
  5510. * @return {DateTime}
  5511. */
  5512. ;
  5513. DateTime.fromMillis = function fromMillis(milliseconds, options) {
  5514. if (options === void 0) {
  5515. options = {};
  5516. }
  5517. if (!isNumber(milliseconds)) {
  5518. throw new InvalidArgumentError("fromMillis requires a numerical input");
  5519. } else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
  5520. // this isn't perfect because because we can still end up out of range because of additional shifting, but it's a start
  5521. return DateTime.invalid("Timestamp out of range");
  5522. } else {
  5523. return new DateTime({
  5524. ts: milliseconds,
  5525. zone: normalizeZone(options.zone, Settings.defaultZone),
  5526. loc: Locale.fromObject(options)
  5527. });
  5528. }
  5529. }
  5530. /**
  5531. * Create a DateTime from a number of seconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
  5532. * @param {number} seconds - a number of seconds since 1970 UTC
  5533. * @param {Object} options - configuration options for the DateTime
  5534. * @param {string|Zone} [options.zone='local'] - the zone to place the DateTime into
  5535. * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
  5536. * @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
  5537. * @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
  5538. * @return {DateTime}
  5539. */
  5540. ;
  5541. DateTime.fromSeconds = function fromSeconds(seconds, options) {
  5542. if (options === void 0) {
  5543. options = {};
  5544. }
  5545. if (!isNumber(seconds)) {
  5546. throw new InvalidArgumentError("fromSeconds requires a numerical input");
  5547. } else {
  5548. return new DateTime({
  5549. ts: seconds * 1000,
  5550. zone: normalizeZone(options.zone, Settings.defaultZone),
  5551. loc: Locale.fromObject(options)
  5552. });
  5553. }
  5554. }
  5555. /**
  5556. * Create a DateTime from a Javascript object with keys like 'year' and 'hour' with reasonable defaults.
  5557. * @param {Object} obj - the object to create the DateTime from
  5558. * @param {number} obj.year - a year, such as 1987
  5559. * @param {number} obj.month - a month, 1-12
  5560. * @param {number} obj.day - a day of the month, 1-31, depending on the month
  5561. * @param {number} obj.ordinal - day of the year, 1-365 or 366
  5562. * @param {number} obj.weekYear - an ISO week year
  5563. * @param {number} obj.weekNumber - an ISO week number, between 1 and 52 or 53, depending on the year
  5564. * @param {number} obj.weekday - an ISO weekday, 1-7, where 1 is Monday and 7 is Sunday
  5565. * @param {number} obj.hour - hour of the day, 0-23
  5566. * @param {number} obj.minute - minute of the hour, 0-59
  5567. * @param {number} obj.second - second of the minute, 0-59
  5568. * @param {number} obj.millisecond - millisecond of the second, 0-999
  5569. * @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()
  5570. * @param {string} [obj.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5571. * @param {string} obj.outputCalendar - the output calendar to set on the resulting DateTime instance
  5572. * @param {string} obj.numberingSystem - the numbering system to set on the resulting DateTime instance
  5573. * @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
  5574. * @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
  5575. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
  5576. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'utc' }),
  5577. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'local' })
  5578. * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'America/New_York' })
  5579. * @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
  5580. * @return {DateTime}
  5581. */
  5582. ;
  5583. DateTime.fromObject = function fromObject(obj) {
  5584. var zoneToUse = normalizeZone(obj.zone, Settings.defaultZone);
  5585. if (!zoneToUse.isValid) {
  5586. return DateTime.invalid(unsupportedZone(zoneToUse));
  5587. }
  5588. var tsNow = Settings.now(),
  5589. offsetProvis = zoneToUse.offset(tsNow),
  5590. normalized = normalizeObject(obj, normalizeUnit, ["zone", "locale", "outputCalendar", "numberingSystem"]),
  5591. containsOrdinal = !isUndefined(normalized.ordinal),
  5592. containsGregorYear = !isUndefined(normalized.year),
  5593. containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
  5594. containsGregor = containsGregorYear || containsGregorMD,
  5595. definiteWeekDef = normalized.weekYear || normalized.weekNumber,
  5596. loc = Locale.fromObject(obj); // cases:
  5597. // just a weekday -> this week's instance of that weekday, no worries
  5598. // (gregorian data or ordinal) + (weekYear or weekNumber) -> error
  5599. // (gregorian month or day) + ordinal -> error
  5600. // otherwise just use weeks or ordinals or gregorian, depending on what's specified
  5601. if ((containsGregor || containsOrdinal) && definiteWeekDef) {
  5602. throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
  5603. }
  5604. if (containsGregorMD && containsOrdinal) {
  5605. throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
  5606. }
  5607. var useWeekData = definiteWeekDef || normalized.weekday && !containsGregor; // configure ourselves to deal with gregorian dates or week stuff
  5608. var units,
  5609. defaultValues,
  5610. objNow = tsToObj(tsNow, offsetProvis);
  5611. if (useWeekData) {
  5612. units = orderedWeekUnits;
  5613. defaultValues = defaultWeekUnitValues;
  5614. objNow = gregorianToWeek(objNow);
  5615. } else if (containsOrdinal) {
  5616. units = orderedOrdinalUnits;
  5617. defaultValues = defaultOrdinalUnitValues;
  5618. objNow = gregorianToOrdinal(objNow);
  5619. } else {
  5620. units = orderedUnits$1;
  5621. defaultValues = defaultUnitValues;
  5622. } // set default values for missing stuff
  5623. var foundFirst = false;
  5624. for (var _iterator2 = units, _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
  5625. var _ref4;
  5626. if (_isArray2) {
  5627. if (_i3 >= _iterator2.length) break;
  5628. _ref4 = _iterator2[_i3++];
  5629. } else {
  5630. _i3 = _iterator2.next();
  5631. if (_i3.done) break;
  5632. _ref4 = _i3.value;
  5633. }
  5634. var u = _ref4;
  5635. var v = normalized[u];
  5636. if (!isUndefined(v)) {
  5637. foundFirst = true;
  5638. } else if (foundFirst) {
  5639. normalized[u] = defaultValues[u];
  5640. } else {
  5641. normalized[u] = objNow[u];
  5642. }
  5643. } // make sure the values we have are in range
  5644. var higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized),
  5645. invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
  5646. if (invalid) {
  5647. return DateTime.invalid(invalid);
  5648. } // compute the actual time
  5649. var gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized,
  5650. _objToTS2 = objToTS(gregorian, offsetProvis, zoneToUse),
  5651. tsFinal = _objToTS2[0],
  5652. offsetFinal = _objToTS2[1],
  5653. inst = new DateTime({
  5654. ts: tsFinal,
  5655. zone: zoneToUse,
  5656. o: offsetFinal,
  5657. loc: loc
  5658. }); // gregorian data + weekday serves only to validate
  5659. if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
  5660. return DateTime.invalid("mismatched weekday", "you can't specify both a weekday of " + normalized.weekday + " and a date of " + inst.toISO());
  5661. }
  5662. return inst;
  5663. }
  5664. /**
  5665. * Create a DateTime from an ISO 8601 string
  5666. * @param {string} text - the ISO string
  5667. * @param {Object} opts - options to affect the creation
  5668. * @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
  5669. * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
  5670. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5671. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5672. * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
  5673. * @example DateTime.fromISO('2016-05-25T09:08:34.123')
  5674. * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
  5675. * @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
  5676. * @example DateTime.fromISO('2016-05-25T09:08:34.123', {zone: 'utc'})
  5677. * @example DateTime.fromISO('2016-W05-4')
  5678. * @return {DateTime}
  5679. */
  5680. ;
  5681. DateTime.fromISO = function fromISO(text, opts) {
  5682. if (opts === void 0) {
  5683. opts = {};
  5684. }
  5685. var _parseISODate = parseISODate(text),
  5686. vals = _parseISODate[0],
  5687. parsedZone = _parseISODate[1];
  5688. return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text);
  5689. }
  5690. /**
  5691. * Create a DateTime from an RFC 2822 string
  5692. * @param {string} text - the RFC 2822 string
  5693. * @param {Object} opts - options to affect the creation
  5694. * @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.
  5695. * @param {boolean} [opts.setZone=false] - override the zone with a fixed-offset zone specified in the string itself, if it specifies one
  5696. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5697. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5698. * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
  5699. * @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
  5700. * @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
  5701. * @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
  5702. * @return {DateTime}
  5703. */
  5704. ;
  5705. DateTime.fromRFC2822 = function fromRFC2822(text, opts) {
  5706. if (opts === void 0) {
  5707. opts = {};
  5708. }
  5709. var _parseRFC2822Date = parseRFC2822Date(text),
  5710. vals = _parseRFC2822Date[0],
  5711. parsedZone = _parseRFC2822Date[1];
  5712. return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text);
  5713. }
  5714. /**
  5715. * Create a DateTime from an HTTP header date
  5716. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
  5717. * @param {string} text - the HTTP header date
  5718. * @param {Object} opts - options to affect the creation
  5719. * @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.
  5720. * @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.
  5721. * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
  5722. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5723. * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
  5724. * @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
  5725. * @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
  5726. * @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
  5727. * @return {DateTime}
  5728. */
  5729. ;
  5730. DateTime.fromHTTP = function fromHTTP(text, opts) {
  5731. if (opts === void 0) {
  5732. opts = {};
  5733. }
  5734. var _parseHTTPDate = parseHTTPDate(text),
  5735. vals = _parseHTTPDate[0],
  5736. parsedZone = _parseHTTPDate[1];
  5737. return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
  5738. }
  5739. /**
  5740. * Create a DateTime from an input string and format string.
  5741. * Defaults to en-US if no locale has been specified, regardless of the system's locale.
  5742. * @see https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens
  5743. * @param {string} text - the string to parse
  5744. * @param {string} fmt - the format the string is expected to be in (see the link below for the formats)
  5745. * @param {Object} opts - options to affect the creation
  5746. * @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
  5747. * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
  5748. * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
  5749. * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
  5750. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5751. * @return {DateTime}
  5752. */
  5753. ;
  5754. DateTime.fromFormat = function fromFormat(text, fmt, opts) {
  5755. if (opts === void 0) {
  5756. opts = {};
  5757. }
  5758. if (isUndefined(text) || isUndefined(fmt)) {
  5759. throw new InvalidArgumentError("fromFormat requires an input string and a format");
  5760. }
  5761. var _opts = opts,
  5762. _opts$locale = _opts.locale,
  5763. locale = _opts$locale === void 0 ? null : _opts$locale,
  5764. _opts$numberingSystem = _opts.numberingSystem,
  5765. numberingSystem = _opts$numberingSystem === void 0 ? null : _opts$numberingSystem,
  5766. localeToUse = Locale.fromOpts({
  5767. locale: locale,
  5768. numberingSystem: numberingSystem,
  5769. defaultToEN: true
  5770. }),
  5771. _parseFromTokens = parseFromTokens(localeToUse, text, fmt),
  5772. vals = _parseFromTokens[0],
  5773. parsedZone = _parseFromTokens[1],
  5774. invalid = _parseFromTokens[2];
  5775. if (invalid) {
  5776. return DateTime.invalid(invalid);
  5777. } else {
  5778. return parseDataToDateTime(vals, parsedZone, opts, "format " + fmt, text);
  5779. }
  5780. }
  5781. /**
  5782. * @deprecated use fromFormat instead
  5783. */
  5784. ;
  5785. DateTime.fromString = function fromString(text, fmt, opts) {
  5786. if (opts === void 0) {
  5787. opts = {};
  5788. }
  5789. return DateTime.fromFormat(text, fmt, opts);
  5790. }
  5791. /**
  5792. * Create a DateTime from a SQL date, time, or datetime
  5793. * Defaults to en-US if no locale has been specified, regardless of the system's locale
  5794. * @param {string} text - the string to parse
  5795. * @param {Object} opts - options to affect the creation
  5796. * @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
  5797. * @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
  5798. * @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
  5799. * @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
  5800. * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
  5801. * @example DateTime.fromSQL('2017-05-15')
  5802. * @example DateTime.fromSQL('2017-05-15 09:12:34')
  5803. * @example DateTime.fromSQL('2017-05-15 09:12:34.342')
  5804. * @example DateTime.fromSQL('2017-05-15 09:12:34.342+06:00')
  5805. * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles')
  5806. * @example DateTime.fromSQL('2017-05-15 09:12:34.342 America/Los_Angeles', { setZone: true })
  5807. * @example DateTime.fromSQL('2017-05-15 09:12:34.342', { zone: 'America/Los_Angeles' })
  5808. * @example DateTime.fromSQL('09:12:34.342')
  5809. * @return {DateTime}
  5810. */
  5811. ;
  5812. DateTime.fromSQL = function fromSQL(text, opts) {
  5813. if (opts === void 0) {
  5814. opts = {};
  5815. }
  5816. var _parseSQL = parseSQL(text),
  5817. vals = _parseSQL[0],
  5818. parsedZone = _parseSQL[1];
  5819. return parseDataToDateTime(vals, parsedZone, opts, "SQL", text);
  5820. }
  5821. /**
  5822. * Create an invalid DateTime.
  5823. * @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
  5824. * @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
  5825. * @return {DateTime}
  5826. */
  5827. ;
  5828. DateTime.invalid = function invalid(reason, explanation) {
  5829. if (explanation === void 0) {
  5830. explanation = null;
  5831. }
  5832. if (!reason) {
  5833. throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
  5834. }
  5835. var invalid = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
  5836. if (Settings.throwOnInvalid) {
  5837. throw new InvalidDateTimeError(invalid);
  5838. } else {
  5839. return new DateTime({
  5840. invalid: invalid
  5841. });
  5842. }
  5843. }
  5844. /**
  5845. * Check if an object is a DateTime. Works across context boundaries
  5846. * @param {object} o
  5847. * @return {boolean}
  5848. */
  5849. ;
  5850. DateTime.isDateTime = function isDateTime(o) {
  5851. return o && o.isLuxonDateTime || false;
  5852. } // INFO
  5853. /**
  5854. * Get the value of unit.
  5855. * @param {string} unit - a unit such as 'minute' or 'day'
  5856. * @example DateTime.local(2017, 7, 4).get('month'); //=> 7
  5857. * @example DateTime.local(2017, 7, 4).get('day'); //=> 4
  5858. * @return {number}
  5859. */
  5860. ;
  5861. var _proto = DateTime.prototype;
  5862. _proto.get = function get(unit) {
  5863. return this[unit];
  5864. }
  5865. /**
  5866. * Returns whether the DateTime is valid. Invalid DateTimes occur when:
  5867. * * The DateTime was created from invalid calendar information, such as the 13th month or February 30
  5868. * * The DateTime was created by an operation on another invalid date
  5869. * @type {boolean}
  5870. */
  5871. ;
  5872. /**
  5873. * Returns the resolved Intl options for this DateTime.
  5874. * This is useful in understanding the behavior of formatting methods
  5875. * @param {Object} opts - the same options as toLocaleString
  5876. * @return {Object}
  5877. */
  5878. _proto.resolvedLocaleOpts = function resolvedLocaleOpts(opts) {
  5879. if (opts === void 0) {
  5880. opts = {};
  5881. }
  5882. var _Formatter$create$res = Formatter.create(this.loc.clone(opts), opts).resolvedOptions(this),
  5883. locale = _Formatter$create$res.locale,
  5884. numberingSystem = _Formatter$create$res.numberingSystem,
  5885. calendar = _Formatter$create$res.calendar;
  5886. return {
  5887. locale: locale,
  5888. numberingSystem: numberingSystem,
  5889. outputCalendar: calendar
  5890. };
  5891. } // TRANSFORM
  5892. /**
  5893. * "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
  5894. *
  5895. * Equivalent to {@link setZone}('utc')
  5896. * @param {number} [offset=0] - optionally, an offset from UTC in minutes
  5897. * @param {Object} [opts={}] - options to pass to `setZone()`
  5898. * @return {DateTime}
  5899. */
  5900. ;
  5901. _proto.toUTC = function toUTC(offset, opts) {
  5902. if (offset === void 0) {
  5903. offset = 0;
  5904. }
  5905. if (opts === void 0) {
  5906. opts = {};
  5907. }
  5908. return this.setZone(FixedOffsetZone.instance(offset), opts);
  5909. }
  5910. /**
  5911. * "Set" the DateTime's zone to the host's local zone. Returns a newly-constructed DateTime.
  5912. *
  5913. * Equivalent to `setZone('local')`
  5914. * @return {DateTime}
  5915. */
  5916. ;
  5917. _proto.toLocal = function toLocal() {
  5918. return this.setZone(Settings.defaultZone);
  5919. }
  5920. /**
  5921. * "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
  5922. *
  5923. * 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.
  5924. * @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.
  5925. * @param {Object} opts - options
  5926. * @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.
  5927. * @return {DateTime}
  5928. */
  5929. ;
  5930. _proto.setZone = function setZone(zone, _temp) {
  5931. var _ref5 = _temp === void 0 ? {} : _temp,
  5932. _ref5$keepLocalTime = _ref5.keepLocalTime,
  5933. keepLocalTime = _ref5$keepLocalTime === void 0 ? false : _ref5$keepLocalTime,
  5934. _ref5$keepCalendarTim = _ref5.keepCalendarTime,
  5935. keepCalendarTime = _ref5$keepCalendarTim === void 0 ? false : _ref5$keepCalendarTim;
  5936. zone = normalizeZone(zone, Settings.defaultZone);
  5937. if (zone.equals(this.zone)) {
  5938. return this;
  5939. } else if (!zone.isValid) {
  5940. return DateTime.invalid(unsupportedZone(zone));
  5941. } else {
  5942. var newTS = this.ts;
  5943. if (keepLocalTime || keepCalendarTime) {
  5944. var offsetGuess = this.o - zone.offset(this.ts);
  5945. var asObj = this.toObject();
  5946. var _objToTS3 = objToTS(asObj, offsetGuess, zone);
  5947. newTS = _objToTS3[0];
  5948. }
  5949. return clone$1(this, {
  5950. ts: newTS,
  5951. zone: zone
  5952. });
  5953. }
  5954. }
  5955. /**
  5956. * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
  5957. * @param {Object} properties - the properties to set
  5958. * @example DateTime.local(2017, 5, 25).reconfigure({ locale: 'en-GB' })
  5959. * @return {DateTime}
  5960. */
  5961. ;
  5962. _proto.reconfigure = function reconfigure(_temp2) {
  5963. var _ref6 = _temp2 === void 0 ? {} : _temp2,
  5964. locale = _ref6.locale,
  5965. numberingSystem = _ref6.numberingSystem,
  5966. outputCalendar = _ref6.outputCalendar;
  5967. var loc = this.loc.clone({
  5968. locale: locale,
  5969. numberingSystem: numberingSystem,
  5970. outputCalendar: outputCalendar
  5971. });
  5972. return clone$1(this, {
  5973. loc: loc
  5974. });
  5975. }
  5976. /**
  5977. * "Set" the locale. Returns a newly-constructed DateTime.
  5978. * Just a convenient alias for reconfigure({ locale })
  5979. * @example DateTime.local(2017, 5, 25).setLocale('en-GB')
  5980. * @return {DateTime}
  5981. */
  5982. ;
  5983. _proto.setLocale = function setLocale(locale) {
  5984. return this.reconfigure({
  5985. locale: locale
  5986. });
  5987. }
  5988. /**
  5989. * "Set" the values of specified units. Returns a newly-constructed DateTime.
  5990. * You can only set units with this method; for "setting" metadata, see {@link reconfigure} and {@link setZone}.
  5991. * @param {Object} values - a mapping of units to numbers
  5992. * @example dt.set({ year: 2017 })
  5993. * @example dt.set({ hour: 8, minute: 30 })
  5994. * @example dt.set({ weekday: 5 })
  5995. * @example dt.set({ year: 2005, ordinal: 234 })
  5996. * @return {DateTime}
  5997. */
  5998. ;
  5999. _proto.set = function set(values) {
  6000. if (!this.isValid) return this;
  6001. var normalized = normalizeObject(values, normalizeUnit, []),
  6002. settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday);
  6003. var mixed;
  6004. if (settingWeekStuff) {
  6005. mixed = weekToGregorian(Object.assign(gregorianToWeek(this.c), normalized));
  6006. } else if (!isUndefined(normalized.ordinal)) {
  6007. mixed = ordinalToGregorian(Object.assign(gregorianToOrdinal(this.c), normalized));
  6008. } else {
  6009. mixed = Object.assign(this.toObject(), normalized); // if we didn't set the day but we ended up on an overflow date,
  6010. // use the last day of the right month
  6011. if (isUndefined(normalized.day)) {
  6012. mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
  6013. }
  6014. }
  6015. var _objToTS4 = objToTS(mixed, this.o, this.zone),
  6016. ts = _objToTS4[0],
  6017. o = _objToTS4[1];
  6018. return clone$1(this, {
  6019. ts: ts,
  6020. o: o
  6021. });
  6022. }
  6023. /**
  6024. * Add a period of time to this DateTime and return the resulting DateTime
  6025. *
  6026. * 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.
  6027. * @param {Duration|Object|number} duration - The amount to add. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  6028. * @example DateTime.local().plus(123) //~> in 123 milliseconds
  6029. * @example DateTime.local().plus({ minutes: 15 }) //~> in 15 minutes
  6030. * @example DateTime.local().plus({ days: 1 }) //~> this time tomorrow
  6031. * @example DateTime.local().plus({ days: -1 }) //~> this time yesterday
  6032. * @example DateTime.local().plus({ hours: 3, minutes: 13 }) //~> in 3 hr, 13 min
  6033. * @example DateTime.local().plus(Duration.fromObject({ hours: 3, minutes: 13 })) //~> in 3 hr, 13 min
  6034. * @return {DateTime}
  6035. */
  6036. ;
  6037. _proto.plus = function plus(duration) {
  6038. if (!this.isValid) return this;
  6039. var dur = friendlyDuration(duration);
  6040. return clone$1(this, adjustTime(this, dur));
  6041. }
  6042. /**
  6043. * Subtract a period of time to this DateTime and return the resulting DateTime
  6044. * See {@link plus}
  6045. * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
  6046. @return {DateTime}
  6047. */
  6048. ;
  6049. _proto.minus = function minus(duration) {
  6050. if (!this.isValid) return this;
  6051. var dur = friendlyDuration(duration).negate();
  6052. return clone$1(this, adjustTime(this, dur));
  6053. }
  6054. /**
  6055. * "Set" this DateTime to the beginning of a unit of time.
  6056. * @param {string} unit - The unit to go to the beginning of. Can be 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.
  6057. * @example DateTime.local(2014, 3, 3).startOf('month').toISODate(); //=> '2014-03-01'
  6058. * @example DateTime.local(2014, 3, 3).startOf('year').toISODate(); //=> '2014-01-01'
  6059. * @example DateTime.local(2014, 3, 3, 5, 30).startOf('day').toISOTime(); //=> '00:00.000-05:00'
  6060. * @example DateTime.local(2014, 3, 3, 5, 30).startOf('hour').toISOTime(); //=> '05:00:00.000-05:00'
  6061. * @return {DateTime}
  6062. */
  6063. ;
  6064. _proto.startOf = function startOf(unit) {
  6065. if (!this.isValid) return this;
  6066. var o = {},
  6067. normalizedUnit = Duration.normalizeUnit(unit);
  6068. switch (normalizedUnit) {
  6069. case "years":
  6070. o.month = 1;
  6071. // falls through
  6072. case "quarters":
  6073. case "months":
  6074. o.day = 1;
  6075. // falls through
  6076. case "weeks":
  6077. case "days":
  6078. o.hour = 0;
  6079. // falls through
  6080. case "hours":
  6081. o.minute = 0;
  6082. // falls through
  6083. case "minutes":
  6084. o.second = 0;
  6085. // falls through
  6086. case "seconds":
  6087. o.millisecond = 0;
  6088. break;
  6089. case "milliseconds":
  6090. break;
  6091. // no default, invalid units throw in normalizeUnit()
  6092. }
  6093. if (normalizedUnit === "weeks") {
  6094. o.weekday = 1;
  6095. }
  6096. if (normalizedUnit === "quarters") {
  6097. var q = Math.ceil(this.month / 3);
  6098. o.month = (q - 1) * 3 + 1;
  6099. }
  6100. return this.set(o);
  6101. }
  6102. /**
  6103. * "Set" this DateTime to the end (meaning the last millisecond) of a unit of time
  6104. * @param {string} unit - The unit to go to the end of. Can be 'year', 'month', 'day', 'hour', 'minute', 'second', or 'millisecond'.
  6105. * @example DateTime.local(2014, 3, 3).endOf('month').toISO(); //=> '2014-03-31T23:59:59.999-05:00'
  6106. * @example DateTime.local(2014, 3, 3).endOf('year').toISO(); //=> '2014-12-31T23:59:59.999-05:00'
  6107. * @example DateTime.local(2014, 3, 3, 5, 30).endOf('day').toISO(); //=> '2014-03-03T23:59:59.999-05:00'
  6108. * @example DateTime.local(2014, 3, 3, 5, 30).endOf('hour').toISO(); //=> '2014-03-03T05:59:59.999-05:00'
  6109. * @return {DateTime}
  6110. */
  6111. ;
  6112. _proto.endOf = function endOf(unit) {
  6113. var _this$plus;
  6114. return this.isValid ? this.plus((_this$plus = {}, _this$plus[unit] = 1, _this$plus)).startOf(unit).minus(1) : this;
  6115. } // OUTPUT
  6116. /**
  6117. * Returns a string representation of this DateTime formatted according to the specified format string.
  6118. * **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).
  6119. * Defaults to en-US if no locale has been specified, regardless of the system's locale.
  6120. * @see https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens
  6121. * @param {string} fmt - the format string
  6122. * @param {Object} opts - opts to override the configuration options
  6123. * @example DateTime.local().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
  6124. * @example DateTime.local().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
  6125. * @example DateTime.local().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
  6126. * @example DateTime.local().toFormat("HH 'hours and' mm 'minutes'") //=> '20 hours and 55 minutes'
  6127. * @return {string}
  6128. */
  6129. ;
  6130. _proto.toFormat = function toFormat(fmt, opts) {
  6131. if (opts === void 0) {
  6132. opts = {};
  6133. }
  6134. return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID$2;
  6135. }
  6136. /**
  6137. * 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`.
  6138. * The exact behavior of this method is browser-specific, but in general it will return an appropriate representation
  6139. * of the DateTime in the assigned locale.
  6140. * Defaults to the system's locale if no locale has been specified
  6141. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
  6142. * @param opts {Object} - Intl.DateTimeFormat constructor options and configuration options
  6143. * @example DateTime.local().toLocaleString(); //=> 4/20/2017
  6144. * @example DateTime.local().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
  6145. * @example DateTime.local().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
  6146. * @example DateTime.local().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
  6147. * @example DateTime.local().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
  6148. * @example DateTime.local().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
  6149. * @example DateTime.local().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
  6150. * @example DateTime.local().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
  6151. * @example DateTime.local().toLocaleString({ hour: '2-digit', minute: '2-digit', hour12: false }); //=> '11:32'
  6152. * @return {string}
  6153. */
  6154. ;
  6155. _proto.toLocaleString = function toLocaleString(opts) {
  6156. if (opts === void 0) {
  6157. opts = DATE_SHORT;
  6158. }
  6159. return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTime(this) : INVALID$2;
  6160. }
  6161. /**
  6162. * 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.
  6163. * Defaults to the system's locale if no locale has been specified
  6164. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/formatToParts
  6165. * @param opts {Object} - Intl.DateTimeFormat constructor options, same as `toLocaleString`.
  6166. * @example DateTime.local().toLocaleString(); //=> [
  6167. * //=> { type: 'day', value: '25' },
  6168. * //=> { type: 'literal', value: '/' },
  6169. * //=> { type: 'month', value: '05' },
  6170. * //=> { type: 'literal', value: '/' },
  6171. * //=> { type: 'year', value: '1982' }
  6172. * //=> ]
  6173. */
  6174. ;
  6175. _proto.toLocaleParts = function toLocaleParts(opts) {
  6176. if (opts === void 0) {
  6177. opts = {};
  6178. }
  6179. return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
  6180. }
  6181. /**
  6182. * Returns an ISO 8601-compliant string representation of this DateTime
  6183. * @param {Object} opts - options
  6184. * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
  6185. * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
  6186. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6187. * @example DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
  6188. * @example DateTime.local().toISO() //=> '2017-04-22T20:47:05.335-04:00'
  6189. * @example DateTime.local().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
  6190. * @return {string}
  6191. */
  6192. ;
  6193. _proto.toISO = function toISO(opts) {
  6194. if (opts === void 0) {
  6195. opts = {};
  6196. }
  6197. if (!this.isValid) {
  6198. return null;
  6199. }
  6200. return this.toISODate() + "T" + this.toISOTime(opts);
  6201. }
  6202. /**
  6203. * Returns an ISO 8601-compliant string representation of this DateTime's date component
  6204. * @example DateTime.utc(1982, 5, 25).toISODate() //=> '1982-05-25'
  6205. * @return {string}
  6206. */
  6207. ;
  6208. _proto.toISODate = function toISODate() {
  6209. var format = "yyyy-MM-dd";
  6210. if (this.year > 9999) {
  6211. format = "+" + format;
  6212. }
  6213. return toTechFormat(this, format);
  6214. }
  6215. /**
  6216. * Returns an ISO 8601-compliant string representation of this DateTime's week date
  6217. * @example DateTime.utc(1982, 5, 25).toISOWeekDate() //=> '1982-W21-2'
  6218. * @return {string}
  6219. */
  6220. ;
  6221. _proto.toISOWeekDate = function toISOWeekDate() {
  6222. return toTechFormat(this, "kkkk-'W'WW-c");
  6223. }
  6224. /**
  6225. * Returns an ISO 8601-compliant string representation of this DateTime's time component
  6226. * @param {Object} opts - options
  6227. * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
  6228. * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
  6229. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6230. * @example DateTime.utc().hour(7).minute(34).toISOTime() //=> '07:34:19.361Z'
  6231. * @example DateTime.utc().hour(7).minute(34).toISOTime({ suppressSeconds: true }) //=> '07:34Z'
  6232. * @return {string}
  6233. */
  6234. ;
  6235. _proto.toISOTime = function toISOTime(_temp3) {
  6236. var _ref7 = _temp3 === void 0 ? {} : _temp3,
  6237. _ref7$suppressMillise = _ref7.suppressMilliseconds,
  6238. suppressMilliseconds = _ref7$suppressMillise === void 0 ? false : _ref7$suppressMillise,
  6239. _ref7$suppressSeconds = _ref7.suppressSeconds,
  6240. suppressSeconds = _ref7$suppressSeconds === void 0 ? false : _ref7$suppressSeconds,
  6241. _ref7$includeOffset = _ref7.includeOffset,
  6242. includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset;
  6243. return toTechTimeFormat(this, {
  6244. suppressSeconds: suppressSeconds,
  6245. suppressMilliseconds: suppressMilliseconds,
  6246. includeOffset: includeOffset
  6247. });
  6248. }
  6249. /**
  6250. * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC
  6251. * @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
  6252. * @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
  6253. * @return {string}
  6254. */
  6255. ;
  6256. _proto.toRFC2822 = function toRFC2822() {
  6257. return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ");
  6258. }
  6259. /**
  6260. * Returns a string representation of this DateTime appropriate for use in HTTP headers.
  6261. * Specifically, the string conforms to RFC 1123.
  6262. * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
  6263. * @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
  6264. * @example DateTime.utc(2014, 7, 13, 19).toHTTP() //=> 'Sun, 13 Jul 2014 19:00:00 GMT'
  6265. * @return {string}
  6266. */
  6267. ;
  6268. _proto.toHTTP = function toHTTP() {
  6269. return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
  6270. }
  6271. /**
  6272. * Returns a string representation of this DateTime appropriate for use in SQL Date
  6273. * @example DateTime.utc(2014, 7, 13).toSQLDate() //=> '2014-07-13'
  6274. * @return {string}
  6275. */
  6276. ;
  6277. _proto.toSQLDate = function toSQLDate() {
  6278. return toTechFormat(this, "yyyy-MM-dd");
  6279. }
  6280. /**
  6281. * Returns a string representation of this DateTime appropriate for use in SQL Time
  6282. * @param {Object} opts - options
  6283. * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
  6284. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6285. * @example DateTime.utc().toSQL() //=> '05:15:16.345'
  6286. * @example DateTime.local().toSQL() //=> '05:15:16.345 -04:00'
  6287. * @example DateTime.local().toSQL({ includeOffset: false }) //=> '05:15:16.345'
  6288. * @example DateTime.local().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
  6289. * @return {string}
  6290. */
  6291. ;
  6292. _proto.toSQLTime = function toSQLTime(_temp4) {
  6293. var _ref8 = _temp4 === void 0 ? {} : _temp4,
  6294. _ref8$includeOffset = _ref8.includeOffset,
  6295. includeOffset = _ref8$includeOffset === void 0 ? true : _ref8$includeOffset,
  6296. _ref8$includeZone = _ref8.includeZone,
  6297. includeZone = _ref8$includeZone === void 0 ? false : _ref8$includeZone;
  6298. return toTechTimeFormat(this, {
  6299. includeOffset: includeOffset,
  6300. includeZone: includeZone,
  6301. spaceZone: true
  6302. });
  6303. }
  6304. /**
  6305. * Returns a string representation of this DateTime appropriate for use in SQL DateTime
  6306. * @param {Object} opts - options
  6307. * @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
  6308. * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
  6309. * @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
  6310. * @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
  6311. * @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
  6312. * @example DateTime.local(2014, 7, 13).toSQL({ includeZone: true }) //=> '2014-07-13 00:00:00.000 America/New_York'
  6313. * @return {string}
  6314. */
  6315. ;
  6316. _proto.toSQL = function toSQL(opts) {
  6317. if (opts === void 0) {
  6318. opts = {};
  6319. }
  6320. if (!this.isValid) {
  6321. return null;
  6322. }
  6323. return this.toSQLDate() + " " + this.toSQLTime(opts);
  6324. }
  6325. /**
  6326. * Returns a string representation of this DateTime appropriate for debugging
  6327. * @return {string}
  6328. */
  6329. ;
  6330. _proto.toString = function toString() {
  6331. return this.isValid ? this.toISO() : INVALID$2;
  6332. }
  6333. /**
  6334. * Returns the epoch milliseconds of this DateTime. Alias of {@link toMillis}
  6335. * @return {number}
  6336. */
  6337. ;
  6338. _proto.valueOf = function valueOf() {
  6339. return this.toMillis();
  6340. }
  6341. /**
  6342. * Returns the epoch milliseconds of this DateTime.
  6343. * @return {number}
  6344. */
  6345. ;
  6346. _proto.toMillis = function toMillis() {
  6347. return this.isValid ? this.ts : NaN;
  6348. }
  6349. /**
  6350. * Returns the epoch seconds of this DateTime.
  6351. * @return {number}
  6352. */
  6353. ;
  6354. _proto.toSeconds = function toSeconds() {
  6355. return this.isValid ? this.ts / 1000 : NaN;
  6356. }
  6357. /**
  6358. * Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
  6359. * @return {string}
  6360. */
  6361. ;
  6362. _proto.toJSON = function toJSON() {
  6363. return this.toISO();
  6364. }
  6365. /**
  6366. * Returns a BSON serializable equivalent to this DateTime.
  6367. * @return {Date}
  6368. */
  6369. ;
  6370. _proto.toBSON = function toBSON() {
  6371. return this.toJSDate();
  6372. }
  6373. /**
  6374. * Returns a Javascript object with this DateTime's year, month, day, and so on.
  6375. * @param opts - options for generating the object
  6376. * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
  6377. * @example DateTime.local().toObject() //=> { year: 2017, month: 4, day: 22, hour: 20, minute: 49, second: 42, millisecond: 268 }
  6378. * @return {Object}
  6379. */
  6380. ;
  6381. _proto.toObject = function toObject(opts) {
  6382. if (opts === void 0) {
  6383. opts = {};
  6384. }
  6385. if (!this.isValid) return {};
  6386. var base = Object.assign({}, this.c);
  6387. if (opts.includeConfig) {
  6388. base.outputCalendar = this.outputCalendar;
  6389. base.numberingSystem = this.loc.numberingSystem;
  6390. base.locale = this.loc.locale;
  6391. }
  6392. return base;
  6393. }
  6394. /**
  6395. * Returns a Javascript Date equivalent to this DateTime.
  6396. * @return {Date}
  6397. */
  6398. ;
  6399. _proto.toJSDate = function toJSDate() {
  6400. return new Date(this.isValid ? this.ts : NaN);
  6401. } // COMPARE
  6402. /**
  6403. * Return the difference between two DateTimes as a Duration.
  6404. * @param {DateTime} otherDateTime - the DateTime to compare this one to
  6405. * @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration.
  6406. * @param {Object} opts - options that affect the creation of the Duration
  6407. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  6408. * @example
  6409. * var i1 = DateTime.fromISO('1982-05-25T09:45'),
  6410. * i2 = DateTime.fromISO('1983-10-14T10:30');
  6411. * i2.diff(i1).toObject() //=> { milliseconds: 43807500000 }
  6412. * i2.diff(i1, 'hours').toObject() //=> { hours: 12168.75 }
  6413. * i2.diff(i1, ['months', 'days']).toObject() //=> { months: 16, days: 19.03125 }
  6414. * i2.diff(i1, ['months', 'days', 'hours']).toObject() //=> { months: 16, days: 19, hours: 0.75 }
  6415. * @return {Duration}
  6416. */
  6417. ;
  6418. _proto.diff = function diff(otherDateTime, unit, opts) {
  6419. if (unit === void 0) {
  6420. unit = "milliseconds";
  6421. }
  6422. if (opts === void 0) {
  6423. opts = {};
  6424. }
  6425. if (!this.isValid || !otherDateTime.isValid) {
  6426. return Duration.invalid(this.invalid || otherDateTime.invalid, "created by diffing an invalid DateTime");
  6427. }
  6428. var durOpts = Object.assign({
  6429. locale: this.locale,
  6430. numberingSystem: this.numberingSystem
  6431. }, opts);
  6432. var units = maybeArray(unit).map(Duration.normalizeUnit),
  6433. otherIsLater = otherDateTime.valueOf() > this.valueOf(),
  6434. earlier = otherIsLater ? this : otherDateTime,
  6435. later = otherIsLater ? otherDateTime : this,
  6436. diffed = _diff(earlier, later, units, durOpts);
  6437. return otherIsLater ? diffed.negate() : diffed;
  6438. }
  6439. /**
  6440. * Return the difference between this DateTime and right now.
  6441. * See {@link diff}
  6442. * @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration
  6443. * @param {Object} opts - options that affect the creation of the Duration
  6444. * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
  6445. * @return {Duration}
  6446. */
  6447. ;
  6448. _proto.diffNow = function diffNow(unit, opts) {
  6449. if (unit === void 0) {
  6450. unit = "milliseconds";
  6451. }
  6452. if (opts === void 0) {
  6453. opts = {};
  6454. }
  6455. return this.diff(DateTime.local(), unit, opts);
  6456. }
  6457. /**
  6458. * Return an Interval spanning between this DateTime and another DateTime
  6459. * @param {DateTime} otherDateTime - the other end point of the Interval
  6460. * @return {Interval}
  6461. */
  6462. ;
  6463. _proto.until = function until(otherDateTime) {
  6464. return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
  6465. }
  6466. /**
  6467. * Return whether this DateTime is in the same unit of time as another DateTime
  6468. * @param {DateTime} otherDateTime - the other DateTime
  6469. * @param {string} unit - the unit of time to check sameness on
  6470. * @example DateTime.local().hasSame(otherDT, 'day'); //~> true if both the same calendar day
  6471. * @return {boolean}
  6472. */
  6473. ;
  6474. _proto.hasSame = function hasSame(otherDateTime, unit) {
  6475. if (!this.isValid) return false;
  6476. if (unit === "millisecond") {
  6477. return this.valueOf() === otherDateTime.valueOf();
  6478. } else {
  6479. var inputMs = otherDateTime.valueOf();
  6480. return this.startOf(unit) <= inputMs && inputMs <= this.endOf(unit);
  6481. }
  6482. }
  6483. /**
  6484. * Equality check
  6485. * Two DateTimes are equal iff they represent the same millisecond, have the same zone and location, and are both valid.
  6486. * To compare just the millisecond values, use `+dt1 === +dt2`.
  6487. * @param {DateTime} other - the other DateTime
  6488. * @return {boolean}
  6489. */
  6490. ;
  6491. _proto.equals = function equals(other) {
  6492. return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
  6493. }
  6494. /**
  6495. * Returns a string representation of a this time relative to now, such as "in two days". Can only internationalize if your
  6496. * platform supports Intl.RelativeTimeFormat. Rounds down by default.
  6497. * @param {Object} options - options that affect the output
  6498. * @param {DateTime} [options.base=DateTime.local()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
  6499. * @param {string} [options.style="long"] - the style of units, must be "long", "short", or "narrow"
  6500. * @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"
  6501. * @param {boolean} [options.round=true] - whether to round the numbers in the output.
  6502. * @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.
  6503. * @param {string} options.locale - override the locale of this DateTime
  6504. * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
  6505. * @example DateTime.local().plus({ days: 1 }).toRelative() //=> "in 1 day"
  6506. * @example DateTime.local().setLocale("es").toRelative({ days: 1 }) //=> "dentro de 1 día"
  6507. * @example DateTime.local().plus({ days: 1 }).toRelative({ locale: "fr" }) //=> "dans 23 heures"
  6508. * @example DateTime.local().minus({ days: 2 }).toRelative() //=> "2 days ago"
  6509. * @example DateTime.local().minus({ days: 2 }).toRelative({ unit: "hours" }) //=> "48 hours ago"
  6510. * @example DateTime.local().minus({ hours: 36 }).toRelative({ round: false }) //=> "1.5 days ago"
  6511. */
  6512. ;
  6513. _proto.toRelative = function toRelative(options) {
  6514. if (options === void 0) {
  6515. options = {};
  6516. }
  6517. if (!this.isValid) return null;
  6518. var base = options.base || DateTime.fromObject({
  6519. zone: this.zone
  6520. }),
  6521. padding = options.padding ? this < base ? -options.padding : options.padding : 0;
  6522. return diffRelative(base, this.plus(padding), Object.assign(options, {
  6523. numeric: "always",
  6524. units: ["years", "months", "days", "hours", "minutes", "seconds"]
  6525. }));
  6526. }
  6527. /**
  6528. * Returns a string representation of this date relative to today, such as "yesterday" or "next month".
  6529. * Only internationalizes on platforms that supports Intl.RelativeTimeFormat.
  6530. * @param {Object} options - options that affect the output
  6531. * @param {DateTime} [options.base=DateTime.local()] - the DateTime to use as the basis to which this time is compared. Defaults to now.
  6532. * @param {string} options.locale - override the locale of this DateTime
  6533. * @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"
  6534. * @param {string} options.numberingSystem - override the numberingSystem of this DateTime. The Intl system may choose not to honor this
  6535. * @example DateTime.local().plus({ days: 1 }).toRelativeCalendar() //=> "tomorrow"
  6536. * @example DateTime.local().setLocale("es").plus({ days: 1 }).toRelative() //=> ""mañana"
  6537. * @example DateTime.local().plus({ days: 1 }).toRelativeCalendar({ locale: "fr" }) //=> "demain"
  6538. * @example DateTime.local().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
  6539. */
  6540. ;
  6541. _proto.toRelativeCalendar = function toRelativeCalendar(options) {
  6542. if (options === void 0) {
  6543. options = {};
  6544. }
  6545. if (!this.isValid) return null;
  6546. return diffRelative(options.base || DateTime.fromObject({
  6547. zone: this.zone
  6548. }), this, Object.assign(options, {
  6549. numeric: "auto",
  6550. units: ["years", "months", "days"],
  6551. calendary: true
  6552. }));
  6553. }
  6554. /**
  6555. * Return the min of several date times
  6556. * @param {...DateTime} dateTimes - the DateTimes from which to choose the minimum
  6557. * @return {DateTime} the min DateTime, or undefined if called with no argument
  6558. */
  6559. ;
  6560. DateTime.min = function min() {
  6561. for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
  6562. dateTimes[_key] = arguments[_key];
  6563. }
  6564. if (!dateTimes.every(DateTime.isDateTime)) {
  6565. throw new InvalidArgumentError("min requires all arguments be DateTimes");
  6566. }
  6567. return bestBy(dateTimes, function (i) {
  6568. return i.valueOf();
  6569. }, Math.min);
  6570. }
  6571. /**
  6572. * Return the max of several date times
  6573. * @param {...DateTime} dateTimes - the DateTimes from which to choose the maximum
  6574. * @return {DateTime} the max DateTime, or undefined if called with no argument
  6575. */
  6576. ;
  6577. DateTime.max = function max() {
  6578. for (var _len2 = arguments.length, dateTimes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6579. dateTimes[_key2] = arguments[_key2];
  6580. }
  6581. if (!dateTimes.every(DateTime.isDateTime)) {
  6582. throw new InvalidArgumentError("max requires all arguments be DateTimes");
  6583. }
  6584. return bestBy(dateTimes, function (i) {
  6585. return i.valueOf();
  6586. }, Math.max);
  6587. } // MISC
  6588. /**
  6589. * Explain how a string would be parsed by fromFormat()
  6590. * @param {string} text - the string to parse
  6591. * @param {string} fmt - the format the string is expected to be in (see description)
  6592. * @param {Object} options - options taken by fromFormat()
  6593. * @return {Object}
  6594. */
  6595. ;
  6596. DateTime.fromFormatExplain = function fromFormatExplain(text, fmt, options) {
  6597. if (options === void 0) {
  6598. options = {};
  6599. }
  6600. var _options = options,
  6601. _options$locale = _options.locale,
  6602. locale = _options$locale === void 0 ? null : _options$locale,
  6603. _options$numberingSys = _options.numberingSystem,
  6604. numberingSystem = _options$numberingSys === void 0 ? null : _options$numberingSys,
  6605. localeToUse = Locale.fromOpts({
  6606. locale: locale,
  6607. numberingSystem: numberingSystem,
  6608. defaultToEN: true
  6609. });
  6610. return explainFromTokens(localeToUse, text, fmt);
  6611. }
  6612. /**
  6613. * @deprecated use fromFormatExplain instead
  6614. */
  6615. ;
  6616. DateTime.fromStringExplain = function fromStringExplain(text, fmt, options) {
  6617. if (options === void 0) {
  6618. options = {};
  6619. }
  6620. return DateTime.fromFormatExplain(text, fmt, options);
  6621. } // FORMAT PRESETS
  6622. /**
  6623. * {@link toLocaleString} format like 10/14/1983
  6624. * @type {Object}
  6625. */
  6626. ;
  6627. _createClass(DateTime, [{
  6628. key: "isValid",
  6629. get: function get() {
  6630. return this.invalid === null;
  6631. }
  6632. /**
  6633. * Returns an error code if this DateTime is invalid, or null if the DateTime is valid
  6634. * @type {string}
  6635. */
  6636. }, {
  6637. key: "invalidReason",
  6638. get: function get() {
  6639. return this.invalid ? this.invalid.reason : null;
  6640. }
  6641. /**
  6642. * Returns an explanation of why this DateTime became invalid, or null if the DateTime is valid
  6643. * @type {string}
  6644. */
  6645. }, {
  6646. key: "invalidExplanation",
  6647. get: function get() {
  6648. return this.invalid ? this.invalid.explanation : null;
  6649. }
  6650. /**
  6651. * Get the locale of a DateTime, such 'en-GB'. The locale is used when formatting the DateTime
  6652. *
  6653. * @type {string}
  6654. */
  6655. }, {
  6656. key: "locale",
  6657. get: function get() {
  6658. return this.isValid ? this.loc.locale : null;
  6659. }
  6660. /**
  6661. * Get the numbering system of a DateTime, such 'beng'. The numbering system is used when formatting the DateTime
  6662. *
  6663. * @type {string}
  6664. */
  6665. }, {
  6666. key: "numberingSystem",
  6667. get: function get() {
  6668. return this.isValid ? this.loc.numberingSystem : null;
  6669. }
  6670. /**
  6671. * Get the output calendar of a DateTime, such 'islamic'. The output calendar is used when formatting the DateTime
  6672. *
  6673. * @type {string}
  6674. */
  6675. }, {
  6676. key: "outputCalendar",
  6677. get: function get() {
  6678. return this.isValid ? this.loc.outputCalendar : null;
  6679. }
  6680. /**
  6681. * Get the time zone associated with this DateTime.
  6682. * @type {Zone}
  6683. */
  6684. }, {
  6685. key: "zone",
  6686. get: function get() {
  6687. return this._zone;
  6688. }
  6689. /**
  6690. * Get the name of the time zone.
  6691. * @type {string}
  6692. */
  6693. }, {
  6694. key: "zoneName",
  6695. get: function get() {
  6696. return this.isValid ? this.zone.name : null;
  6697. }
  6698. /**
  6699. * Get the year
  6700. * @example DateTime.local(2017, 5, 25).year //=> 2017
  6701. * @type {number}
  6702. */
  6703. }, {
  6704. key: "year",
  6705. get: function get() {
  6706. return this.isValid ? this.c.year : NaN;
  6707. }
  6708. /**
  6709. * Get the quarter
  6710. * @example DateTime.local(2017, 5, 25).quarter //=> 2
  6711. * @type {number}
  6712. */
  6713. }, {
  6714. key: "quarter",
  6715. get: function get() {
  6716. return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
  6717. }
  6718. /**
  6719. * Get the month (1-12).
  6720. * @example DateTime.local(2017, 5, 25).month //=> 5
  6721. * @type {number}
  6722. */
  6723. }, {
  6724. key: "month",
  6725. get: function get() {
  6726. return this.isValid ? this.c.month : NaN;
  6727. }
  6728. /**
  6729. * Get the day of the month (1-30ish).
  6730. * @example DateTime.local(2017, 5, 25).day //=> 25
  6731. * @type {number}
  6732. */
  6733. }, {
  6734. key: "day",
  6735. get: function get() {
  6736. return this.isValid ? this.c.day : NaN;
  6737. }
  6738. /**
  6739. * Get the hour of the day (0-23).
  6740. * @example DateTime.local(2017, 5, 25, 9).hour //=> 9
  6741. * @type {number}
  6742. */
  6743. }, {
  6744. key: "hour",
  6745. get: function get() {
  6746. return this.isValid ? this.c.hour : NaN;
  6747. }
  6748. /**
  6749. * Get the minute of the hour (0-59).
  6750. * @example DateTime.local(2017, 5, 25, 9, 30).minute //=> 30
  6751. * @type {number}
  6752. */
  6753. }, {
  6754. key: "minute",
  6755. get: function get() {
  6756. return this.isValid ? this.c.minute : NaN;
  6757. }
  6758. /**
  6759. * Get the second of the minute (0-59).
  6760. * @example DateTime.local(2017, 5, 25, 9, 30, 52).second //=> 52
  6761. * @type {number}
  6762. */
  6763. }, {
  6764. key: "second",
  6765. get: function get() {
  6766. return this.isValid ? this.c.second : NaN;
  6767. }
  6768. /**
  6769. * Get the millisecond of the second (0-999).
  6770. * @example DateTime.local(2017, 5, 25, 9, 30, 52, 654).millisecond //=> 654
  6771. * @type {number}
  6772. */
  6773. }, {
  6774. key: "millisecond",
  6775. get: function get() {
  6776. return this.isValid ? this.c.millisecond : NaN;
  6777. }
  6778. /**
  6779. * Get the week year
  6780. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6781. * @example DateTime.local(2014, 11, 31).weekYear //=> 2015
  6782. * @type {number}
  6783. */
  6784. }, {
  6785. key: "weekYear",
  6786. get: function get() {
  6787. return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
  6788. }
  6789. /**
  6790. * Get the week number of the week year (1-52ish).
  6791. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6792. * @example DateTime.local(2017, 5, 25).weekNumber //=> 21
  6793. * @type {number}
  6794. */
  6795. }, {
  6796. key: "weekNumber",
  6797. get: function get() {
  6798. return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
  6799. }
  6800. /**
  6801. * Get the day of the week.
  6802. * 1 is Monday and 7 is Sunday
  6803. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6804. * @example DateTime.local(2014, 11, 31).weekday //=> 4
  6805. * @type {number}
  6806. */
  6807. }, {
  6808. key: "weekday",
  6809. get: function get() {
  6810. return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
  6811. }
  6812. /**
  6813. * Get the ordinal (meaning the day of the year)
  6814. * @example DateTime.local(2017, 5, 25).ordinal //=> 145
  6815. * @type {number|DateTime}
  6816. */
  6817. }, {
  6818. key: "ordinal",
  6819. get: function get() {
  6820. return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
  6821. }
  6822. /**
  6823. * Get the human readable short month name, such as 'Oct'.
  6824. * Defaults to the system's locale if no locale has been specified
  6825. * @example DateTime.local(2017, 10, 30).monthShort //=> Oct
  6826. * @type {string}
  6827. */
  6828. }, {
  6829. key: "monthShort",
  6830. get: function get() {
  6831. return this.isValid ? Info.months("short", {
  6832. locale: this.locale
  6833. })[this.month - 1] : null;
  6834. }
  6835. /**
  6836. * Get the human readable long month name, such as 'October'.
  6837. * Defaults to the system's locale if no locale has been specified
  6838. * @example DateTime.local(2017, 10, 30).monthLong //=> October
  6839. * @type {string}
  6840. */
  6841. }, {
  6842. key: "monthLong",
  6843. get: function get() {
  6844. return this.isValid ? Info.months("long", {
  6845. locale: this.locale
  6846. })[this.month - 1] : null;
  6847. }
  6848. /**
  6849. * Get the human readable short weekday, such as 'Mon'.
  6850. * Defaults to the system's locale if no locale has been specified
  6851. * @example DateTime.local(2017, 10, 30).weekdayShort //=> Mon
  6852. * @type {string}
  6853. */
  6854. }, {
  6855. key: "weekdayShort",
  6856. get: function get() {
  6857. return this.isValid ? Info.weekdays("short", {
  6858. locale: this.locale
  6859. })[this.weekday - 1] : null;
  6860. }
  6861. /**
  6862. * Get the human readable long weekday, such as 'Monday'.
  6863. * Defaults to the system's locale if no locale has been specified
  6864. * @example DateTime.local(2017, 10, 30).weekdayLong //=> Monday
  6865. * @type {string}
  6866. */
  6867. }, {
  6868. key: "weekdayLong",
  6869. get: function get() {
  6870. return this.isValid ? Info.weekdays("long", {
  6871. locale: this.locale
  6872. })[this.weekday - 1] : null;
  6873. }
  6874. /**
  6875. * Get the UTC offset of this DateTime in minutes
  6876. * @example DateTime.local().offset //=> -240
  6877. * @example DateTime.utc().offset //=> 0
  6878. * @type {number}
  6879. */
  6880. }, {
  6881. key: "offset",
  6882. get: function get() {
  6883. return this.isValid ? +this.o : NaN;
  6884. }
  6885. /**
  6886. * Get the short human name for the zone's current offset, for example "EST" or "EDT".
  6887. * Defaults to the system's locale if no locale has been specified
  6888. * @type {string}
  6889. */
  6890. }, {
  6891. key: "offsetNameShort",
  6892. get: function get() {
  6893. if (this.isValid) {
  6894. return this.zone.offsetName(this.ts, {
  6895. format: "short",
  6896. locale: this.locale
  6897. });
  6898. } else {
  6899. return null;
  6900. }
  6901. }
  6902. /**
  6903. * Get the long human name for the zone's current offset, for example "Eastern Standard Time" or "Eastern Daylight Time".
  6904. * Defaults to the system's locale if no locale has been specified
  6905. * @type {string}
  6906. */
  6907. }, {
  6908. key: "offsetNameLong",
  6909. get: function get() {
  6910. if (this.isValid) {
  6911. return this.zone.offsetName(this.ts, {
  6912. format: "long",
  6913. locale: this.locale
  6914. });
  6915. } else {
  6916. return null;
  6917. }
  6918. }
  6919. /**
  6920. * Get whether this zone's offset ever changes, as in a DST.
  6921. * @type {boolean}
  6922. */
  6923. }, {
  6924. key: "isOffsetFixed",
  6925. get: function get() {
  6926. return this.isValid ? this.zone.universal : null;
  6927. }
  6928. /**
  6929. * Get whether the DateTime is in a DST.
  6930. * @type {boolean}
  6931. */
  6932. }, {
  6933. key: "isInDST",
  6934. get: function get() {
  6935. if (this.isOffsetFixed) {
  6936. return false;
  6937. } else {
  6938. return this.offset > this.set({
  6939. month: 1
  6940. }).offset || this.offset > this.set({
  6941. month: 5
  6942. }).offset;
  6943. }
  6944. }
  6945. /**
  6946. * Returns true if this DateTime is in a leap year, false otherwise
  6947. * @example DateTime.local(2016).isInLeapYear //=> true
  6948. * @example DateTime.local(2013).isInLeapYear //=> false
  6949. * @type {boolean}
  6950. */
  6951. }, {
  6952. key: "isInLeapYear",
  6953. get: function get() {
  6954. return isLeapYear(this.year);
  6955. }
  6956. /**
  6957. * Returns the number of days in this DateTime's month
  6958. * @example DateTime.local(2016, 2).daysInMonth //=> 29
  6959. * @example DateTime.local(2016, 3).daysInMonth //=> 31
  6960. * @type {number}
  6961. */
  6962. }, {
  6963. key: "daysInMonth",
  6964. get: function get() {
  6965. return daysInMonth(this.year, this.month);
  6966. }
  6967. /**
  6968. * Returns the number of days in this DateTime's year
  6969. * @example DateTime.local(2016).daysInYear //=> 366
  6970. * @example DateTime.local(2013).daysInYear //=> 365
  6971. * @type {number}
  6972. */
  6973. }, {
  6974. key: "daysInYear",
  6975. get: function get() {
  6976. return this.isValid ? daysInYear(this.year) : NaN;
  6977. }
  6978. /**
  6979. * Returns the number of weeks in this DateTime's year
  6980. * @see https://en.wikipedia.org/wiki/ISO_week_date
  6981. * @example DateTime.local(2004).weeksInWeekYear //=> 53
  6982. * @example DateTime.local(2013).weeksInWeekYear //=> 52
  6983. * @type {number}
  6984. */
  6985. }, {
  6986. key: "weeksInWeekYear",
  6987. get: function get() {
  6988. return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
  6989. }
  6990. }], [{
  6991. key: "DATE_SHORT",
  6992. get: function get() {
  6993. return DATE_SHORT;
  6994. }
  6995. /**
  6996. * {@link toLocaleString} format like 'Oct 14, 1983'
  6997. * @type {Object}
  6998. */
  6999. }, {
  7000. key: "DATE_MED",
  7001. get: function get() {
  7002. return DATE_MED;
  7003. }
  7004. /**
  7005. * {@link toLocaleString} format like 'October 14, 1983'
  7006. * @type {Object}
  7007. */
  7008. }, {
  7009. key: "DATE_FULL",
  7010. get: function get() {
  7011. return DATE_FULL;
  7012. }
  7013. /**
  7014. * {@link toLocaleString} format like 'Tuesday, October 14, 1983'
  7015. * @type {Object}
  7016. */
  7017. }, {
  7018. key: "DATE_HUGE",
  7019. get: function get() {
  7020. return DATE_HUGE;
  7021. }
  7022. /**
  7023. * {@link toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
  7024. * @type {Object}
  7025. */
  7026. }, {
  7027. key: "TIME_SIMPLE",
  7028. get: function get() {
  7029. return TIME_SIMPLE;
  7030. }
  7031. /**
  7032. * {@link toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
  7033. * @type {Object}
  7034. */
  7035. }, {
  7036. key: "TIME_WITH_SECONDS",
  7037. get: function get() {
  7038. return TIME_WITH_SECONDS;
  7039. }
  7040. /**
  7041. * {@link toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
  7042. * @type {Object}
  7043. */
  7044. }, {
  7045. key: "TIME_WITH_SHORT_OFFSET",
  7046. get: function get() {
  7047. return TIME_WITH_SHORT_OFFSET;
  7048. }
  7049. /**
  7050. * {@link toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7051. * @type {Object}
  7052. */
  7053. }, {
  7054. key: "TIME_WITH_LONG_OFFSET",
  7055. get: function get() {
  7056. return TIME_WITH_LONG_OFFSET;
  7057. }
  7058. /**
  7059. * {@link toLocaleString} format like '09:30', always 24-hour.
  7060. * @type {Object}
  7061. */
  7062. }, {
  7063. key: "TIME_24_SIMPLE",
  7064. get: function get() {
  7065. return TIME_24_SIMPLE;
  7066. }
  7067. /**
  7068. * {@link toLocaleString} format like '09:30:23', always 24-hour.
  7069. * @type {Object}
  7070. */
  7071. }, {
  7072. key: "TIME_24_WITH_SECONDS",
  7073. get: function get() {
  7074. return TIME_24_WITH_SECONDS;
  7075. }
  7076. /**
  7077. * {@link toLocaleString} format like '09:30:23 EDT', always 24-hour.
  7078. * @type {Object}
  7079. */
  7080. }, {
  7081. key: "TIME_24_WITH_SHORT_OFFSET",
  7082. get: function get() {
  7083. return TIME_24_WITH_SHORT_OFFSET;
  7084. }
  7085. /**
  7086. * {@link toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
  7087. * @type {Object}
  7088. */
  7089. }, {
  7090. key: "TIME_24_WITH_LONG_OFFSET",
  7091. get: function get() {
  7092. return TIME_24_WITH_LONG_OFFSET;
  7093. }
  7094. /**
  7095. * {@link toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
  7096. * @type {Object}
  7097. */
  7098. }, {
  7099. key: "DATETIME_SHORT",
  7100. get: function get() {
  7101. return DATETIME_SHORT;
  7102. }
  7103. /**
  7104. * {@link toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
  7105. * @type {Object}
  7106. */
  7107. }, {
  7108. key: "DATETIME_SHORT_WITH_SECONDS",
  7109. get: function get() {
  7110. return DATETIME_SHORT_WITH_SECONDS;
  7111. }
  7112. /**
  7113. * {@link toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
  7114. * @type {Object}
  7115. */
  7116. }, {
  7117. key: "DATETIME_MED",
  7118. get: function get() {
  7119. return DATETIME_MED;
  7120. }
  7121. /**
  7122. * {@link toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
  7123. * @type {Object}
  7124. */
  7125. }, {
  7126. key: "DATETIME_MED_WITH_SECONDS",
  7127. get: function get() {
  7128. return DATETIME_MED_WITH_SECONDS;
  7129. }
  7130. /**
  7131. * {@link toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
  7132. * @type {Object}
  7133. */
  7134. }, {
  7135. key: "DATETIME_MED_WITH_WEEKDAY",
  7136. get: function get() {
  7137. return DATETIME_MED_WITH_WEEKDAY;
  7138. }
  7139. /**
  7140. * {@link toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
  7141. * @type {Object}
  7142. */
  7143. }, {
  7144. key: "DATETIME_FULL",
  7145. get: function get() {
  7146. return DATETIME_FULL;
  7147. }
  7148. /**
  7149. * {@link toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
  7150. * @type {Object}
  7151. */
  7152. }, {
  7153. key: "DATETIME_FULL_WITH_SECONDS",
  7154. get: function get() {
  7155. return DATETIME_FULL_WITH_SECONDS;
  7156. }
  7157. /**
  7158. * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7159. * @type {Object}
  7160. */
  7161. }, {
  7162. key: "DATETIME_HUGE",
  7163. get: function get() {
  7164. return DATETIME_HUGE;
  7165. }
  7166. /**
  7167. * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
  7168. * @type {Object}
  7169. */
  7170. }, {
  7171. key: "DATETIME_HUGE_WITH_SECONDS",
  7172. get: function get() {
  7173. return DATETIME_HUGE_WITH_SECONDS;
  7174. }
  7175. }]);
  7176. return DateTime;
  7177. }();
  7178. function friendlyDateTime(dateTimeish) {
  7179. if (DateTime.isDateTime(dateTimeish)) {
  7180. return dateTimeish;
  7181. } else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) {
  7182. return DateTime.fromJSDate(dateTimeish);
  7183. } else if (dateTimeish && typeof dateTimeish === "object") {
  7184. return DateTime.fromObject(dateTimeish);
  7185. } else {
  7186. throw new InvalidArgumentError("Unknown datetime argument: " + dateTimeish + ", of type " + typeof dateTimeish);
  7187. }
  7188. }
  7189. exports.DateTime = DateTime;
  7190. exports.Duration = Duration;
  7191. exports.FixedOffsetZone = FixedOffsetZone;
  7192. exports.IANAZone = IANAZone;
  7193. exports.Info = Info;
  7194. exports.Interval = Interval;
  7195. exports.InvalidZone = InvalidZone;
  7196. exports.LocalZone = LocalZone;
  7197. exports.Settings = Settings;
  7198. exports.Zone = Zone;
  7199. //# sourceMappingURL=luxon.js.map
  7200. /***/ }),
  7201. /* 1 */
  7202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7203. "use strict";
  7204. __webpack_require__.r(__webpack_exports__);
  7205. // CONCATENATED MODULE: ./src/weekday.ts
  7206. // =============================================================================
  7207. // Weekday
  7208. // =============================================================================
  7209. var ALL_WEEKDAYS = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'];
  7210. var Weekday = /** @class */ (function () {
  7211. function Weekday(weekday, n) {
  7212. if (n === 0)
  7213. throw new Error("Can't create weekday with n == 0");
  7214. this.weekday = weekday;
  7215. this.n = n;
  7216. }
  7217. Weekday.fromStr = function (str) {
  7218. return new Weekday(ALL_WEEKDAYS.indexOf(str));
  7219. };
  7220. // __call__ - Cannot call the object directly, do it through
  7221. // e.g. RRule.TH.nth(-1) instead,
  7222. Weekday.prototype.nth = function (n) {
  7223. return this.n === n ? this : new Weekday(this.weekday, n);
  7224. };
  7225. // __eq__
  7226. Weekday.prototype.equals = function (other) {
  7227. return this.weekday === other.weekday && this.n === other.n;
  7228. };
  7229. // __repr__
  7230. Weekday.prototype.toString = function () {
  7231. var s = ALL_WEEKDAYS[this.weekday];
  7232. if (this.n)
  7233. s = (this.n > 0 ? '+' : '') + String(this.n) + s;
  7234. return s;
  7235. };
  7236. Weekday.prototype.getJsWeekday = function () {
  7237. return this.weekday === 6 ? 0 : this.weekday + 1;
  7238. };
  7239. return Weekday;
  7240. }());
  7241. // CONCATENATED MODULE: ./src/helpers.ts
  7242. // =============================================================================
  7243. // Helper functions
  7244. // =============================================================================
  7245. var isPresent = function (value) {
  7246. return value !== null && value !== undefined;
  7247. };
  7248. var isNumber = function (value) {
  7249. return typeof value === 'number';
  7250. };
  7251. var isWeekdayStr = function (value) {
  7252. return ALL_WEEKDAYS.indexOf(value) >= 0;
  7253. };
  7254. var isArray = Array.isArray;
  7255. /**
  7256. * Simplified version of python's range()
  7257. */
  7258. var range = function (start, end) {
  7259. if (end === void 0) { end = start; }
  7260. if (arguments.length === 1) {
  7261. end = start;
  7262. start = 0;
  7263. }
  7264. var rang = [];
  7265. for (var i = start; i < end; i++)
  7266. rang.push(i);
  7267. return rang;
  7268. };
  7269. var clone = function (array) {
  7270. return [].concat(array);
  7271. };
  7272. var repeat = function (value, times) {
  7273. var i = 0;
  7274. var array = [];
  7275. if (isArray(value)) {
  7276. for (; i < times; i++)
  7277. array[i] = [].concat(value);
  7278. }
  7279. else {
  7280. for (; i < times; i++)
  7281. array[i] = value;
  7282. }
  7283. return array;
  7284. };
  7285. var toArray = function (item) {
  7286. if (isArray(item)) {
  7287. return item;
  7288. }
  7289. return [item];
  7290. };
  7291. function padStart(item, targetLength, padString) {
  7292. if (padString === void 0) { padString = ' '; }
  7293. var str = String(item);
  7294. targetLength = targetLength >> 0;
  7295. if (str.length > targetLength) {
  7296. return String(str);
  7297. }
  7298. targetLength = targetLength - str.length;
  7299. if (targetLength > padString.length) {
  7300. padString += repeat(padString, targetLength / padString.length);
  7301. }
  7302. return padString.slice(0, targetLength) + String(str);
  7303. }
  7304. /**
  7305. * Python like split
  7306. */
  7307. var split = function (str, sep, num) {
  7308. var splits = str.split(sep);
  7309. return num
  7310. ? splits.slice(0, num).concat([splits.slice(num).join(sep)])
  7311. : splits;
  7312. };
  7313. /**
  7314. * closure/goog/math/math.js:modulo
  7315. * Copyright 2006 The Closure Library Authors.
  7316. * The % operator in JavaScript returns the remainder of a / b, but differs from
  7317. * some other languages in that the result will have the same sign as the
  7318. * dividend. For example, -1 % 8 == -1, whereas in some other languages
  7319. * (such as Python) the result would be 7. This function emulates the more
  7320. * correct modulo behavior, which is useful for certain applications such as
  7321. * calculating an offset index in a circular list.
  7322. *
  7323. * @param {number} a The dividend.
  7324. * @param {number} b The divisor.
  7325. * @return {number} a % b where the result is between 0 and b (either 0 <= x < b
  7326. * or b < x <= 0, depending on the sign of b).
  7327. */
  7328. var pymod = function (a, b) {
  7329. var r = a % b;
  7330. // If r and b differ in sign, add b to wrap the result to the correct sign.
  7331. return r * b < 0 ? r + b : r;
  7332. };
  7333. /**
  7334. * @see: <http://docs.python.org/library/functions.html#divmod>
  7335. */
  7336. var divmod = function (a, b) {
  7337. return { div: Math.floor(a / b), mod: pymod(a, b) };
  7338. };
  7339. var empty = function (obj) {
  7340. return !isPresent(obj) || obj.length === 0;
  7341. };
  7342. /**
  7343. * Python-like boolean
  7344. * @return {Boolean} value of an object/primitive, taking into account
  7345. * the fact that in Python an empty list's/tuple's
  7346. * boolean value is False, whereas in JS it's true
  7347. */
  7348. var notEmpty = function (obj) {
  7349. return !empty(obj);
  7350. };
  7351. /**
  7352. * Return true if a value is in an array
  7353. */
  7354. var includes = function (arr, val) {
  7355. return notEmpty(arr) && arr.indexOf(val) !== -1;
  7356. };
  7357. // CONCATENATED MODULE: ./src/dateutil.ts
  7358. /**
  7359. * General date-related utilities.
  7360. * Also handles several incompatibilities between JavaScript and Python
  7361. *
  7362. */
  7363. var dateutil_dateutil;
  7364. (function (dateutil) {
  7365. dateutil.MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  7366. /**
  7367. * Number of milliseconds of one day
  7368. */
  7369. dateutil.ONE_DAY = 1000 * 60 * 60 * 24;
  7370. /**
  7371. * @see: <http://docs.python.org/library/datetime.html#datetime.MAXYEAR>
  7372. */
  7373. dateutil.MAXYEAR = 9999;
  7374. /**
  7375. * Python uses 1-Jan-1 as the base for calculating ordinals but we don't
  7376. * want to confuse the JS engine with milliseconds > Number.MAX_NUMBER,
  7377. * therefore we use 1-Jan-1970 instead
  7378. */
  7379. dateutil.ORDINAL_BASE = new Date(Date.UTC(1970, 0, 1));
  7380. /**
  7381. * Python: MO-SU: 0 - 6
  7382. * JS: SU-SAT 0 - 6
  7383. */
  7384. dateutil.PY_WEEKDAYS = [6, 0, 1, 2, 3, 4, 5];
  7385. /**
  7386. * py_date.timetuple()[7]
  7387. */
  7388. dateutil.getYearDay = function (date) {
  7389. var dateNoTime = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
  7390. return (Math.ceil((dateNoTime.valueOf() -
  7391. new Date(date.getUTCFullYear(), 0, 1).valueOf()) /
  7392. dateutil.ONE_DAY) + 1);
  7393. };
  7394. dateutil.isLeapYear = function (year) {
  7395. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  7396. };
  7397. dateutil.isDate = function (value) {
  7398. return value instanceof Date;
  7399. };
  7400. dateutil.isValidDate = function (value) {
  7401. return dateutil.isDate(value) && !isNaN(value.getTime());
  7402. };
  7403. /**
  7404. * @return {Number} the date's timezone offset in ms
  7405. */
  7406. dateutil.tzOffset = function (date) {
  7407. return date.getTimezoneOffset() * 60 * 1000;
  7408. };
  7409. /**
  7410. * @see: <http://www.mcfedries.com/JavaScript/DaysBetween.asp>
  7411. */
  7412. dateutil.daysBetween = function (date1, date2) {
  7413. // The number of milliseconds in one day
  7414. // Convert both dates to milliseconds
  7415. var date1ms = date1.getTime() - dateutil.tzOffset(date1);
  7416. var date2ms = date2.getTime() - dateutil.tzOffset(date2);
  7417. // Calculate the difference in milliseconds
  7418. var differencems = date1ms - date2ms;
  7419. // Convert back to days and return
  7420. return Math.round(differencems / dateutil.ONE_DAY);
  7421. };
  7422. /**
  7423. * @see: <http://docs.python.org/library/datetime.html#datetime.date.toordinal>
  7424. */
  7425. dateutil.toOrdinal = function (date) {
  7426. return dateutil.daysBetween(date, dateutil.ORDINAL_BASE);
  7427. };
  7428. /**
  7429. * @see - <http://docs.python.org/library/datetime.html#datetime.date.fromordinal>
  7430. */
  7431. dateutil.fromOrdinal = function (ordinal) {
  7432. return new Date(dateutil.ORDINAL_BASE.getTime() + ordinal * dateutil.ONE_DAY);
  7433. };
  7434. dateutil.getMonthDays = function (date) {
  7435. var month = date.getUTCMonth();
  7436. return month === 1 && dateutil.isLeapYear(date.getUTCFullYear())
  7437. ? 29
  7438. : dateutil.MONTH_DAYS[month];
  7439. };
  7440. /**
  7441. * @return {Number} python-like weekday
  7442. */
  7443. dateutil.getWeekday = function (date) {
  7444. return dateutil.PY_WEEKDAYS[date.getUTCDay()];
  7445. };
  7446. /**
  7447. * @see: <http://docs.python.org/library/calendar.html#calendar.monthrange>
  7448. */
  7449. dateutil.monthRange = function (year, month) {
  7450. var date = new Date(Date.UTC(year, month, 1));
  7451. return [dateutil.getWeekday(date), dateutil.getMonthDays(date)];
  7452. };
  7453. /**
  7454. * @see: <http://docs.python.org/library/datetime.html#datetime.datetime.combine>
  7455. */
  7456. dateutil.combine = function (date, time) {
  7457. time = time || date;
  7458. return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()));
  7459. };
  7460. dateutil.clone = function (date) {
  7461. var dolly = new Date(date.getTime());
  7462. return dolly;
  7463. };
  7464. dateutil.cloneDates = function (dates) {
  7465. var clones = [];
  7466. for (var i = 0; i < dates.length; i++) {
  7467. clones.push(dateutil.clone(dates[i]));
  7468. }
  7469. return clones;
  7470. };
  7471. /**
  7472. * Sorts an array of Date or dateutil.Time objects
  7473. */
  7474. dateutil.sort = function (dates) {
  7475. dates.sort(function (a, b) {
  7476. return a.getTime() - b.getTime();
  7477. });
  7478. };
  7479. dateutil.timeToUntilString = function (time, utc) {
  7480. if (utc === void 0) { utc = true; }
  7481. var date = new Date(time);
  7482. return [
  7483. padStart(date.getUTCFullYear().toString(), 4, '0'),
  7484. padStart(date.getUTCMonth() + 1, 2, '0'),
  7485. padStart(date.getUTCDate(), 2, '0'),
  7486. 'T',
  7487. padStart(date.getUTCHours(), 2, '0'),
  7488. padStart(date.getUTCMinutes(), 2, '0'),
  7489. padStart(date.getUTCSeconds(), 2, '0'),
  7490. utc ? 'Z' : ''
  7491. ].join('');
  7492. };
  7493. dateutil.untilStringToDate = function (until) {
  7494. var re = /^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/;
  7495. var bits = re.exec(until);
  7496. if (!bits)
  7497. throw new Error("Invalid UNTIL value: " + until);
  7498. return new Date(Date.UTC(parseInt(bits[1], 10), parseInt(bits[2], 10) - 1, parseInt(bits[3], 10), parseInt(bits[5], 10) || 0, parseInt(bits[6], 10) || 0, parseInt(bits[7], 10) || 0));
  7499. };
  7500. })(dateutil_dateutil || (dateutil_dateutil = {}));
  7501. /* harmony default export */ var src_dateutil = (dateutil_dateutil);
  7502. // CONCATENATED MODULE: ./src/iterresult.ts
  7503. /**
  7504. * This class helps us to emulate python's generators, sorta.
  7505. */
  7506. var IterResult = /** @class */ (function () {
  7507. function IterResult(method, args) {
  7508. this.minDate = null;
  7509. this.maxDate = null;
  7510. this._result = [];
  7511. this.total = 0;
  7512. this.method = method;
  7513. this.args = args;
  7514. if (method === 'between') {
  7515. this.maxDate = args.inc
  7516. ? args.before
  7517. : new Date(args.before.getTime() - 1);
  7518. this.minDate = args.inc ? args.after : new Date(args.after.getTime() + 1);
  7519. }
  7520. else if (method === 'before') {
  7521. this.maxDate = args.inc ? args.dt : new Date(args.dt.getTime() - 1);
  7522. }
  7523. else if (method === 'after') {
  7524. this.minDate = args.inc ? args.dt : new Date(args.dt.getTime() + 1);
  7525. }
  7526. }
  7527. /**
  7528. * Possibly adds a date into the result.
  7529. *
  7530. * @param {Date} date - the date isn't necessarly added to the result
  7531. * list (if it is too late/too early)
  7532. * @return {Boolean} true if it makes sense to continue the iteration
  7533. * false if we're done.
  7534. */
  7535. IterResult.prototype.accept = function (date) {
  7536. ++this.total;
  7537. var tooEarly = this.minDate && date < this.minDate;
  7538. var tooLate = this.maxDate && date > this.maxDate;
  7539. if (this.method === 'between') {
  7540. if (tooEarly)
  7541. return true;
  7542. if (tooLate)
  7543. return false;
  7544. }
  7545. else if (this.method === 'before') {
  7546. if (tooLate)
  7547. return false;
  7548. }
  7549. else if (this.method === 'after') {
  7550. if (tooEarly)
  7551. return true;
  7552. this.add(date);
  7553. return false;
  7554. }
  7555. return this.add(date);
  7556. };
  7557. /**
  7558. *
  7559. * @param {Date} date that is part of the result.
  7560. * @return {Boolean} whether we are interested in more values.
  7561. */
  7562. IterResult.prototype.add = function (date) {
  7563. this._result.push(date);
  7564. return true;
  7565. };
  7566. /**
  7567. * 'before' and 'after' return only one date, whereas 'all'
  7568. * and 'between' an array.
  7569. * @return {Date,Array?}
  7570. */
  7571. IterResult.prototype.getValue = function () {
  7572. var res = this._result;
  7573. switch (this.method) {
  7574. case 'all':
  7575. case 'between':
  7576. return res;
  7577. case 'before':
  7578. case 'after':
  7579. default:
  7580. return (res.length ? res[res.length - 1] : null);
  7581. }
  7582. };
  7583. IterResult.prototype.clone = function () {
  7584. return new IterResult(this.method, this.args);
  7585. };
  7586. return IterResult;
  7587. }());
  7588. /* harmony default export */ var iterresult = (IterResult);
  7589. // CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
  7590. /*! *****************************************************************************
  7591. Copyright (c) Microsoft Corporation. All rights reserved.
  7592. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  7593. this file except in compliance with the License. You may obtain a copy of the
  7594. License at http://www.apache.org/licenses/LICENSE-2.0
  7595. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7596. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  7597. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  7598. MERCHANTABLITY OR NON-INFRINGEMENT.
  7599. See the Apache Version 2.0 License for specific language governing permissions
  7600. and limitations under the License.
  7601. ***************************************************************************** */
  7602. /* global Reflect, Promise */
  7603. var extendStatics = function(d, b) {
  7604. extendStatics = Object.setPrototypeOf ||
  7605. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  7606. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7607. return extendStatics(d, b);
  7608. };
  7609. function __extends(d, b) {
  7610. extendStatics(d, b);
  7611. function __() { this.constructor = d; }
  7612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7613. }
  7614. var __assign = function() {
  7615. __assign = Object.assign || function __assign(t) {
  7616. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7617. s = arguments[i];
  7618. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7619. }
  7620. return t;
  7621. }
  7622. return __assign.apply(this, arguments);
  7623. }
  7624. function __rest(s, e) {
  7625. var t = {};
  7626. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  7627. t[p] = s[p];
  7628. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  7629. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7630. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  7631. t[p[i]] = s[p[i]];
  7632. }
  7633. return t;
  7634. }
  7635. function __decorate(decorators, target, key, desc) {
  7636. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7637. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  7638. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  7639. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7640. }
  7641. function __param(paramIndex, decorator) {
  7642. return function (target, key) { decorator(target, key, paramIndex); }
  7643. }
  7644. function __metadata(metadataKey, metadataValue) {
  7645. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  7646. }
  7647. function __awaiter(thisArg, _arguments, P, generator) {
  7648. return new (P || (P = Promise))(function (resolve, reject) {
  7649. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  7650. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  7651. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  7652. step((generator = generator.apply(thisArg, _arguments || [])).next());
  7653. });
  7654. }
  7655. function __generator(thisArg, body) {
  7656. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  7657. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  7658. function verb(n) { return function (v) { return step([n, v]); }; }
  7659. function step(op) {
  7660. if (f) throw new TypeError("Generator is already executing.");
  7661. while (_) try {
  7662. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  7663. if (y = 0, t) op = [op[0] & 2, t.value];
  7664. switch (op[0]) {
  7665. case 0: case 1: t = op; break;
  7666. case 4: _.label++; return { value: op[1], done: false };
  7667. case 5: _.label++; y = op[1]; op = [0]; continue;
  7668. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  7669. default:
  7670. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  7671. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  7672. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  7673. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  7674. if (t[2]) _.ops.pop();
  7675. _.trys.pop(); continue;
  7676. }
  7677. op = body.call(thisArg, _);
  7678. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  7679. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  7680. }
  7681. }
  7682. function __exportStar(m, exports) {
  7683. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  7684. }
  7685. function __values(o) {
  7686. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  7687. if (m) return m.call(o);
  7688. return {
  7689. next: function () {
  7690. if (o && i >= o.length) o = void 0;
  7691. return { value: o && o[i++], done: !o };
  7692. }
  7693. };
  7694. }
  7695. function __read(o, n) {
  7696. var m = typeof Symbol === "function" && o[Symbol.iterator];
  7697. if (!m) return o;
  7698. var i = m.call(o), r, ar = [], e;
  7699. try {
  7700. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  7701. }
  7702. catch (error) { e = { error: error }; }
  7703. finally {
  7704. try {
  7705. if (r && !r.done && (m = i["return"])) m.call(i);
  7706. }
  7707. finally { if (e) throw e.error; }
  7708. }
  7709. return ar;
  7710. }
  7711. function __spread() {
  7712. for (var ar = [], i = 0; i < arguments.length; i++)
  7713. ar = ar.concat(__read(arguments[i]));
  7714. return ar;
  7715. }
  7716. function __spreadArrays() {
  7717. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  7718. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  7719. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  7720. r[k] = a[j];
  7721. return r;
  7722. };
  7723. function __await(v) {
  7724. return this instanceof __await ? (this.v = v, this) : new __await(v);
  7725. }
  7726. function __asyncGenerator(thisArg, _arguments, generator) {
  7727. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  7728. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  7729. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  7730. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  7731. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  7732. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  7733. function fulfill(value) { resume("next", value); }
  7734. function reject(value) { resume("throw", value); }
  7735. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  7736. }
  7737. function __asyncDelegator(o) {
  7738. var i, p;
  7739. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  7740. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  7741. }
  7742. function __asyncValues(o) {
  7743. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  7744. var m = o[Symbol.asyncIterator], i;
  7745. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  7746. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  7747. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  7748. }
  7749. function __makeTemplateObject(cooked, raw) {
  7750. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  7751. return cooked;
  7752. };
  7753. function __importStar(mod) {
  7754. if (mod && mod.__esModule) return mod;
  7755. var result = {};
  7756. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  7757. result.default = mod;
  7758. return result;
  7759. }
  7760. function __importDefault(mod) {
  7761. return (mod && mod.__esModule) ? mod : { default: mod };
  7762. }
  7763. // CONCATENATED MODULE: ./src/callbackiterresult.ts
  7764. /**
  7765. * IterResult subclass that calls a callback function on each add,
  7766. * and stops iterating when the callback returns false.
  7767. */
  7768. var callbackiterresult_CallbackIterResult = /** @class */ (function (_super) {
  7769. __extends(CallbackIterResult, _super);
  7770. function CallbackIterResult(method, args, iterator) {
  7771. var _this = _super.call(this, method, args) || this;
  7772. _this.iterator = iterator;
  7773. return _this;
  7774. }
  7775. CallbackIterResult.prototype.add = function (date) {
  7776. if (this.iterator(date, this._result.length)) {
  7777. this._result.push(date);
  7778. return true;
  7779. }
  7780. return false;
  7781. };
  7782. return CallbackIterResult;
  7783. }(iterresult));
  7784. /* harmony default export */ var callbackiterresult = (callbackiterresult_CallbackIterResult);
  7785. // CONCATENATED MODULE: ./src/nlp/i18n.ts
  7786. // =============================================================================
  7787. // i18n
  7788. // =============================================================================
  7789. var ENGLISH = {
  7790. dayNames: [
  7791. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  7792. 'Thursday', 'Friday', 'Saturday'
  7793. ],
  7794. monthNames: [
  7795. 'January', 'February', 'March', 'April', 'May',
  7796. 'June', 'July', 'August', 'September', 'October',
  7797. 'November', 'December'
  7798. ],
  7799. tokens: {
  7800. 'SKIP': /^[ \r\n\t]+|^\.$/,
  7801. 'number': /^[1-9][0-9]*/,
  7802. 'numberAsText': /^(one|two|three)/i,
  7803. 'every': /^every/i,
  7804. 'day(s)': /^days?/i,
  7805. 'weekday(s)': /^weekdays?/i,
  7806. 'week(s)': /^weeks?/i,
  7807. 'hour(s)': /^hours?/i,
  7808. 'minute(s)': /^minutes?/i,
  7809. 'month(s)': /^months?/i,
  7810. 'year(s)': /^years?/i,
  7811. 'on': /^(on|in)/i,
  7812. 'at': /^(at)/i,
  7813. 'the': /^the/i,
  7814. 'first': /^first/i,
  7815. 'second': /^second/i,
  7816. 'third': /^third/i,
  7817. 'nth': /^([1-9][0-9]*)(\.|th|nd|rd|st)/i,
  7818. 'last': /^last/i,
  7819. 'for': /^for/i,
  7820. 'time(s)': /^times?/i,
  7821. 'until': /^(un)?til/i,
  7822. 'monday': /^mo(n(day)?)?/i,
  7823. 'tuesday': /^tu(e(s(day)?)?)?/i,
  7824. 'wednesday': /^we(d(n(esday)?)?)?/i,
  7825. 'thursday': /^th(u(r(sday)?)?)?/i,
  7826. 'friday': /^fr(i(day)?)?/i,
  7827. 'saturday': /^sa(t(urday)?)?/i,
  7828. 'sunday': /^su(n(day)?)?/i,
  7829. 'january': /^jan(uary)?/i,
  7830. 'february': /^feb(ruary)?/i,
  7831. 'march': /^mar(ch)?/i,
  7832. 'april': /^apr(il)?/i,
  7833. 'may': /^may/i,
  7834. 'june': /^june?/i,
  7835. 'july': /^july?/i,
  7836. 'august': /^aug(ust)?/i,
  7837. 'september': /^sep(t(ember)?)?/i,
  7838. 'october': /^oct(ober)?/i,
  7839. 'november': /^nov(ember)?/i,
  7840. 'december': /^dec(ember)?/i,
  7841. 'comma': /^(,\s*|(and|or)\s*)+/i
  7842. }
  7843. };
  7844. /* harmony default export */ var i18n = (ENGLISH);
  7845. // CONCATENATED MODULE: ./src/nlp/totext.ts
  7846. // =============================================================================
  7847. // Helper functions
  7848. // =============================================================================
  7849. /**
  7850. * Return true if a value is in an array
  7851. */
  7852. var contains = function (arr, val) {
  7853. return arr.indexOf(val) !== -1;
  7854. };
  7855. var defaultGetText = function (id) { return id.toString(); };
  7856. var defaultDateFormatter = function (year, month, day) { return month + " " + day + ", " + year; };
  7857. /**
  7858. *
  7859. * @param {RRule} rrule
  7860. * Optional:
  7861. * @param {Function} gettext function
  7862. * @param {Object} language definition
  7863. * @constructor
  7864. */
  7865. var totext_ToText = /** @class */ (function () {
  7866. function ToText(rrule, gettext, language, dateFormatter) {
  7867. if (gettext === void 0) { gettext = defaultGetText; }
  7868. if (language === void 0) { language = i18n; }
  7869. if (dateFormatter === void 0) { dateFormatter = defaultDateFormatter; }
  7870. this.text = [];
  7871. this.language = language || i18n;
  7872. this.gettext = gettext;
  7873. this.dateFormatter = dateFormatter;
  7874. this.rrule = rrule;
  7875. this.options = rrule.options;
  7876. this.origOptions = rrule.origOptions;
  7877. if (this.origOptions.bymonthday) {
  7878. var bymonthday = [].concat(this.options.bymonthday);
  7879. var bynmonthday = [].concat(this.options.bynmonthday);
  7880. bymonthday.sort(function (a, b) { return a - b; });
  7881. bynmonthday.sort(function (a, b) { return b - a; });
  7882. // 1, 2, 3, .., -5, -4, -3, ..
  7883. this.bymonthday = bymonthday.concat(bynmonthday);
  7884. if (!this.bymonthday.length)
  7885. this.bymonthday = null;
  7886. }
  7887. if (isPresent(this.origOptions.byweekday)) {
  7888. var byweekday = !isArray(this.origOptions.byweekday)
  7889. ? [this.origOptions.byweekday]
  7890. : this.origOptions.byweekday;
  7891. var days = String(byweekday);
  7892. this.byweekday = {
  7893. allWeeks: byweekday.filter(function (weekday) {
  7894. return !weekday.n;
  7895. }),
  7896. someWeeks: byweekday.filter(function (weekday) {
  7897. return Boolean(weekday.n);
  7898. }),
  7899. isWeekdays: days.indexOf('MO') !== -1 &&
  7900. days.indexOf('TU') !== -1 &&
  7901. days.indexOf('WE') !== -1 &&
  7902. days.indexOf('TH') !== -1 &&
  7903. days.indexOf('FR') !== -1 &&
  7904. days.indexOf('SA') === -1 &&
  7905. days.indexOf('SU') === -1,
  7906. isEveryDay: days.indexOf('MO') !== -1 &&
  7907. days.indexOf('TU') !== -1 &&
  7908. days.indexOf('WE') !== -1 &&
  7909. days.indexOf('TH') !== -1 &&
  7910. days.indexOf('FR') !== -1 &&
  7911. days.indexOf('SA') !== -1 &&
  7912. days.indexOf('SU') !== -1
  7913. };
  7914. var sortWeekDays = function (a, b) {
  7915. return a.weekday - b.weekday;
  7916. };
  7917. this.byweekday.allWeeks.sort(sortWeekDays);
  7918. this.byweekday.someWeeks.sort(sortWeekDays);
  7919. if (!this.byweekday.allWeeks.length)
  7920. this.byweekday.allWeeks = null;
  7921. if (!this.byweekday.someWeeks.length)
  7922. this.byweekday.someWeeks = null;
  7923. }
  7924. else {
  7925. this.byweekday = null;
  7926. }
  7927. }
  7928. /**
  7929. * Test whether the rrule can be fully converted to text.
  7930. * @param {RRule} rrule
  7931. * @return {Boolean}
  7932. */
  7933. ToText.isFullyConvertible = function (rrule) {
  7934. var canConvert = true;
  7935. if (!(rrule.options.freq in ToText.IMPLEMENTED))
  7936. return false;
  7937. if (rrule.origOptions.until && rrule.origOptions.count)
  7938. return false;
  7939. for (var key in rrule.origOptions) {
  7940. if (contains(['dtstart', 'wkst', 'freq'], key))
  7941. return true;
  7942. if (!contains(ToText.IMPLEMENTED[rrule.options.freq], key))
  7943. return false;
  7944. }
  7945. return canConvert;
  7946. };
  7947. ToText.prototype.isFullyConvertible = function () {
  7948. return ToText.isFullyConvertible(this.rrule);
  7949. };
  7950. /**
  7951. * Perform the conversion. Only some of the frequencies are supported.
  7952. * If some of the rrule's options aren't supported, they'll
  7953. * be omitted from the output an "(~ approximate)" will be appended.
  7954. * @return {*}
  7955. */
  7956. ToText.prototype.toString = function () {
  7957. var gettext = this.gettext;
  7958. if (!(this.options.freq in ToText.IMPLEMENTED)) {
  7959. return gettext('RRule error: Unable to fully convert this rrule to text');
  7960. }
  7961. this.text = [gettext('every')];
  7962. // @ts-ignore
  7963. this[src.FREQUENCIES[this.options.freq]]();
  7964. if (this.options.until) {
  7965. this.add(gettext('until'));
  7966. var until = this.options.until;
  7967. this.add(this.dateFormatter(until.getUTCFullYear(), this.language.monthNames[until.getUTCMonth()], until.getUTCDate()));
  7968. }
  7969. else if (this.options.count) {
  7970. this.add(gettext('for'))
  7971. .add(this.options.count.toString())
  7972. .add(this.plural(this.options.count) ? gettext('times') : gettext('time'));
  7973. }
  7974. if (!this.isFullyConvertible())
  7975. this.add(gettext('(~ approximate)'));
  7976. return this.text.join('');
  7977. };
  7978. ToText.prototype.HOURLY = function () {
  7979. var gettext = this.gettext;
  7980. if (this.options.interval !== 1)
  7981. this.add(this.options.interval.toString());
  7982. this.add(this.plural(this.options.interval) ? gettext('hours') : gettext('hour'));
  7983. };
  7984. ToText.prototype.MINUTELY = function () {
  7985. var gettext = this.gettext;
  7986. if (this.options.interval !== 1)
  7987. this.add(this.options.interval.toString());
  7988. this.add(this.plural(this.options.interval)
  7989. ? gettext('minutes')
  7990. : gettext('minute'));
  7991. };
  7992. ToText.prototype.DAILY = function () {
  7993. var gettext = this.gettext;
  7994. if (this.options.interval !== 1)
  7995. this.add(this.options.interval.toString());
  7996. if (this.byweekday && this.byweekday.isWeekdays) {
  7997. this.add(this.plural(this.options.interval)
  7998. ? gettext('weekdays')
  7999. : gettext('weekday'));
  8000. }
  8001. else {
  8002. this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
  8003. }
  8004. if (this.origOptions.bymonth) {
  8005. this.add(gettext('in'));
  8006. this._bymonth();
  8007. }
  8008. if (this.bymonthday) {
  8009. this._bymonthday();
  8010. }
  8011. else if (this.byweekday) {
  8012. this._byweekday();
  8013. }
  8014. else if (this.origOptions.byhour) {
  8015. this._byhour();
  8016. }
  8017. };
  8018. ToText.prototype.WEEKLY = function () {
  8019. var gettext = this.gettext;
  8020. if (this.options.interval !== 1) {
  8021. this.add(this.options.interval.toString()).add(this.plural(this.options.interval) ? gettext('weeks') : gettext('week'));
  8022. }
  8023. if (this.byweekday && this.byweekday.isWeekdays) {
  8024. if (this.options.interval === 1) {
  8025. this.add(this.plural(this.options.interval)
  8026. ? gettext('weekdays')
  8027. : gettext('weekday'));
  8028. }
  8029. else {
  8030. this.add(gettext('on')).add(gettext('weekdays'));
  8031. }
  8032. }
  8033. else if (this.byweekday && this.byweekday.isEveryDay) {
  8034. this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
  8035. }
  8036. else {
  8037. if (this.options.interval === 1)
  8038. this.add(gettext('week'));
  8039. if (this.origOptions.bymonth) {
  8040. this.add(gettext('in'));
  8041. this._bymonth();
  8042. }
  8043. if (this.bymonthday) {
  8044. this._bymonthday();
  8045. }
  8046. else if (this.byweekday) {
  8047. this._byweekday();
  8048. }
  8049. }
  8050. };
  8051. ToText.prototype.MONTHLY = function () {
  8052. var gettext = this.gettext;
  8053. if (this.origOptions.bymonth) {
  8054. if (this.options.interval !== 1) {
  8055. this.add(this.options.interval.toString()).add(gettext('months'));
  8056. if (this.plural(this.options.interval))
  8057. this.add(gettext('in'));
  8058. }
  8059. else {
  8060. // this.add(gettext('MONTH'))
  8061. }
  8062. this._bymonth();
  8063. }
  8064. else {
  8065. if (this.options.interval !== 1)
  8066. this.add(this.options.interval.toString());
  8067. this.add(this.plural(this.options.interval)
  8068. ? gettext('months')
  8069. : gettext('month'));
  8070. }
  8071. if (this.bymonthday) {
  8072. this._bymonthday();
  8073. }
  8074. else if (this.byweekday && this.byweekday.isWeekdays) {
  8075. this.add(gettext('on')).add(gettext('weekdays'));
  8076. }
  8077. else if (this.byweekday) {
  8078. this._byweekday();
  8079. }
  8080. };
  8081. ToText.prototype.YEARLY = function () {
  8082. var gettext = this.gettext;
  8083. if (this.origOptions.bymonth) {
  8084. if (this.options.interval !== 1) {
  8085. this.add(this.options.interval.toString());
  8086. this.add(gettext('years'));
  8087. }
  8088. else {
  8089. // this.add(gettext('YEAR'))
  8090. }
  8091. this._bymonth();
  8092. }
  8093. else {
  8094. if (this.options.interval !== 1)
  8095. this.add(this.options.interval.toString());
  8096. this.add(this.plural(this.options.interval) ? gettext('years') : gettext('year'));
  8097. }
  8098. if (this.bymonthday) {
  8099. this._bymonthday();
  8100. }
  8101. else if (this.byweekday) {
  8102. this._byweekday();
  8103. }
  8104. if (this.options.byyearday) {
  8105. this.add(gettext('on the'))
  8106. .add(this.list(this.options.byyearday, this.nth, gettext('and')))
  8107. .add(gettext('day'));
  8108. }
  8109. if (this.options.byweekno) {
  8110. this.add(gettext('in'))
  8111. .add(this.plural(this.options.byweekno.length)
  8112. ? gettext('weeks')
  8113. : gettext('week'))
  8114. .add(this.list(this.options.byweekno, undefined, gettext('and')));
  8115. }
  8116. };
  8117. ToText.prototype._bymonthday = function () {
  8118. var gettext = this.gettext;
  8119. if (this.byweekday && this.byweekday.allWeeks) {
  8120. this.add(gettext('on'))
  8121. .add(this.list(this.byweekday.allWeeks, this.weekdaytext, gettext('or')))
  8122. .add(gettext('the'))
  8123. .add(this.list(this.bymonthday, this.nth, gettext('or')));
  8124. }
  8125. else {
  8126. this.add(gettext('on the')).add(this.list(this.bymonthday, this.nth, gettext('and')));
  8127. }
  8128. // this.add(gettext('DAY'))
  8129. };
  8130. ToText.prototype._byweekday = function () {
  8131. var gettext = this.gettext;
  8132. if (this.byweekday.allWeeks && !this.byweekday.isWeekdays) {
  8133. this.add(gettext('on')).add(this.list(this.byweekday.allWeeks, this.weekdaytext));
  8134. }
  8135. if (this.byweekday.someWeeks) {
  8136. if (this.byweekday.allWeeks)
  8137. this.add(gettext('and'));
  8138. this.add(gettext('on the')).add(this.list(this.byweekday.someWeeks, this.weekdaytext, gettext('and')));
  8139. }
  8140. };
  8141. ToText.prototype._byhour = function () {
  8142. var gettext = this.gettext;
  8143. this.add(gettext('at')).add(this.list(this.origOptions.byhour, undefined, gettext('and')));
  8144. };
  8145. ToText.prototype._bymonth = function () {
  8146. this.add(this.list(this.options.bymonth, this.monthtext, this.gettext('and')));
  8147. };
  8148. ToText.prototype.nth = function (n) {
  8149. n = parseInt(n.toString(), 10);
  8150. var nth;
  8151. var npos;
  8152. var gettext = this.gettext;
  8153. if (n === -1)
  8154. return gettext('last');
  8155. npos = Math.abs(n);
  8156. switch (npos) {
  8157. case 1:
  8158. case 21:
  8159. case 31:
  8160. nth = npos + gettext('st');
  8161. break;
  8162. case 2:
  8163. case 22:
  8164. nth = npos + gettext('nd');
  8165. break;
  8166. case 3:
  8167. case 23:
  8168. nth = npos + gettext('rd');
  8169. break;
  8170. default:
  8171. nth = npos + gettext('th');
  8172. }
  8173. return n < 0 ? nth + ' ' + gettext('last') : nth;
  8174. };
  8175. ToText.prototype.monthtext = function (m) {
  8176. return this.language.monthNames[m - 1];
  8177. };
  8178. ToText.prototype.weekdaytext = function (wday) {
  8179. var weekday = isNumber(wday) ? (wday + 1) % 7 : wday.getJsWeekday();
  8180. return ((wday.n ? this.nth(wday.n) + ' ' : '') + this.language.dayNames[weekday]);
  8181. };
  8182. ToText.prototype.plural = function (n) {
  8183. return n % 100 !== 1;
  8184. };
  8185. ToText.prototype.add = function (s) {
  8186. this.text.push(' ');
  8187. this.text.push(s);
  8188. return this;
  8189. };
  8190. ToText.prototype.list = function (arr, callback, finalDelim, delim) {
  8191. if (delim === void 0) { delim = ','; }
  8192. if (!isArray(arr)) {
  8193. arr = [arr];
  8194. }
  8195. var delimJoin = function (array, delimiter, finalDelimiter) {
  8196. var list = '';
  8197. for (var i = 0; i < array.length; i++) {
  8198. if (i !== 0) {
  8199. if (i === array.length - 1) {
  8200. list += ' ' + finalDelimiter + ' ';
  8201. }
  8202. else {
  8203. list += delimiter + ' ';
  8204. }
  8205. }
  8206. list += array[i];
  8207. }
  8208. return list;
  8209. };
  8210. callback =
  8211. callback ||
  8212. function (o) {
  8213. return o.toString();
  8214. };
  8215. var self = this;
  8216. var realCallback = function (arg) {
  8217. return callback && callback.call(self, arg);
  8218. };
  8219. if (finalDelim) {
  8220. return delimJoin(arr.map(realCallback), delim, finalDelim);
  8221. }
  8222. else {
  8223. return arr.map(realCallback).join(delim + ' ');
  8224. }
  8225. };
  8226. return ToText;
  8227. }());
  8228. /* harmony default export */ var totext = (totext_ToText);
  8229. // CONCATENATED MODULE: ./src/nlp/parsetext.ts
  8230. // =============================================================================
  8231. // Parser
  8232. // =============================================================================
  8233. var Parser = /** @class */ (function () {
  8234. function Parser(rules) {
  8235. this.done = true;
  8236. this.rules = rules;
  8237. }
  8238. Parser.prototype.start = function (text) {
  8239. this.text = text;
  8240. this.done = false;
  8241. return this.nextSymbol();
  8242. };
  8243. Parser.prototype.isDone = function () {
  8244. return this.done && this.symbol === null;
  8245. };
  8246. Parser.prototype.nextSymbol = function () {
  8247. var best;
  8248. var bestSymbol;
  8249. var p = this;
  8250. this.symbol = null;
  8251. this.value = null;
  8252. do {
  8253. if (this.done)
  8254. return false;
  8255. var rule = void 0;
  8256. best = null;
  8257. for (var name_1 in this.rules) {
  8258. rule = this.rules[name_1];
  8259. var match = rule.exec(p.text);
  8260. if (match) {
  8261. if (best === null || match[0].length > best[0].length) {
  8262. best = match;
  8263. bestSymbol = name_1;
  8264. }
  8265. }
  8266. }
  8267. if (best != null) {
  8268. this.text = this.text.substr(best[0].length);
  8269. if (this.text === '')
  8270. this.done = true;
  8271. }
  8272. if (best == null) {
  8273. this.done = true;
  8274. this.symbol = null;
  8275. this.value = null;
  8276. return;
  8277. }
  8278. // @ts-ignore
  8279. } while (bestSymbol === 'SKIP');
  8280. // @ts-ignore
  8281. this.symbol = bestSymbol;
  8282. this.value = best;
  8283. return true;
  8284. };
  8285. Parser.prototype.accept = function (name) {
  8286. if (this.symbol === name) {
  8287. if (this.value) {
  8288. var v = this.value;
  8289. this.nextSymbol();
  8290. return v;
  8291. }
  8292. this.nextSymbol();
  8293. return true;
  8294. }
  8295. return false;
  8296. };
  8297. Parser.prototype.acceptNumber = function () {
  8298. return this.accept('number');
  8299. };
  8300. Parser.prototype.expect = function (name) {
  8301. if (this.accept(name))
  8302. return true;
  8303. throw new Error('expected ' + name + ' but found ' + this.symbol);
  8304. };
  8305. return Parser;
  8306. }());
  8307. function parseText(text, language) {
  8308. if (language === void 0) { language = i18n; }
  8309. var options = {};
  8310. var ttr = new Parser(language.tokens);
  8311. if (!ttr.start(text))
  8312. return null;
  8313. S();
  8314. return options;
  8315. function S() {
  8316. // every [n]
  8317. ttr.expect('every');
  8318. var n = ttr.acceptNumber();
  8319. if (n)
  8320. options.interval = parseInt(n[0], 10);
  8321. if (ttr.isDone())
  8322. throw new Error('Unexpected end');
  8323. switch (ttr.symbol) {
  8324. case 'day(s)':
  8325. options.freq = src.DAILY;
  8326. if (ttr.nextSymbol()) {
  8327. AT();
  8328. F();
  8329. }
  8330. break;
  8331. // FIXME Note: every 2 weekdays != every two weeks on weekdays.
  8332. // DAILY on weekdays is not a valid rule
  8333. case 'weekday(s)':
  8334. options.freq = src.WEEKLY;
  8335. options.byweekday = [
  8336. src.MO,
  8337. src.TU,
  8338. src.WE,
  8339. src.TH,
  8340. src.FR
  8341. ];
  8342. ttr.nextSymbol();
  8343. F();
  8344. break;
  8345. case 'week(s)':
  8346. options.freq = src.WEEKLY;
  8347. if (ttr.nextSymbol()) {
  8348. ON();
  8349. F();
  8350. }
  8351. break;
  8352. case 'hour(s)':
  8353. options.freq = src.HOURLY;
  8354. if (ttr.nextSymbol()) {
  8355. ON();
  8356. F();
  8357. }
  8358. break;
  8359. case 'minute(s)':
  8360. options.freq = src.MINUTELY;
  8361. if (ttr.nextSymbol()) {
  8362. ON();
  8363. F();
  8364. }
  8365. break;
  8366. case 'month(s)':
  8367. options.freq = src.MONTHLY;
  8368. if (ttr.nextSymbol()) {
  8369. ON();
  8370. F();
  8371. }
  8372. break;
  8373. case 'year(s)':
  8374. options.freq = src.YEARLY;
  8375. if (ttr.nextSymbol()) {
  8376. ON();
  8377. F();
  8378. }
  8379. break;
  8380. case 'monday':
  8381. case 'tuesday':
  8382. case 'wednesday':
  8383. case 'thursday':
  8384. case 'friday':
  8385. case 'saturday':
  8386. case 'sunday':
  8387. options.freq = src.WEEKLY;
  8388. var key = ttr.symbol.substr(0, 2).toUpperCase();
  8389. options.byweekday = [src[key]];
  8390. if (!ttr.nextSymbol())
  8391. return;
  8392. // TODO check for duplicates
  8393. while (ttr.accept('comma')) {
  8394. if (ttr.isDone())
  8395. throw new Error('Unexpected end');
  8396. var wkd = decodeWKD();
  8397. if (!wkd) {
  8398. throw new Error('Unexpected symbol ' + ttr.symbol + ', expected weekday');
  8399. }
  8400. // @ts-ignore
  8401. options.byweekday.push(src[wkd]);
  8402. ttr.nextSymbol();
  8403. }
  8404. MDAYs();
  8405. F();
  8406. break;
  8407. case 'january':
  8408. case 'february':
  8409. case 'march':
  8410. case 'april':
  8411. case 'may':
  8412. case 'june':
  8413. case 'july':
  8414. case 'august':
  8415. case 'september':
  8416. case 'october':
  8417. case 'november':
  8418. case 'december':
  8419. options.freq = src.YEARLY;
  8420. options.bymonth = [decodeM()];
  8421. if (!ttr.nextSymbol())
  8422. return;
  8423. // TODO check for duplicates
  8424. while (ttr.accept('comma')) {
  8425. if (ttr.isDone())
  8426. throw new Error('Unexpected end');
  8427. var m = decodeM();
  8428. if (!m) {
  8429. throw new Error('Unexpected symbol ' + ttr.symbol + ', expected month');
  8430. }
  8431. options.bymonth.push(m);
  8432. ttr.nextSymbol();
  8433. }
  8434. ON();
  8435. F();
  8436. break;
  8437. default:
  8438. throw new Error('Unknown symbol');
  8439. }
  8440. }
  8441. function ON() {
  8442. var on = ttr.accept('on');
  8443. var the = ttr.accept('the');
  8444. if (!(on || the))
  8445. return;
  8446. do {
  8447. var nth = decodeNTH();
  8448. var wkd = decodeWKD();
  8449. var m = decodeM();
  8450. // nth <weekday> | <weekday>
  8451. if (nth) {
  8452. // ttr.nextSymbol()
  8453. if (wkd) {
  8454. ttr.nextSymbol();
  8455. if (!options.byweekday)
  8456. options.byweekday = [];
  8457. // @ts-ignore
  8458. options.byweekday.push(src[wkd].nth(nth));
  8459. }
  8460. else {
  8461. if (!options.bymonthday)
  8462. options.bymonthday = [];
  8463. // @ts-ignore
  8464. options.bymonthday.push(nth);
  8465. ttr.accept('day(s)');
  8466. }
  8467. // <weekday>
  8468. }
  8469. else if (wkd) {
  8470. ttr.nextSymbol();
  8471. if (!options.byweekday)
  8472. options.byweekday = [];
  8473. // @ts-ignore
  8474. options.byweekday.push(src[wkd]);
  8475. }
  8476. else if (ttr.symbol === 'weekday(s)') {
  8477. ttr.nextSymbol();
  8478. if (!options.byweekday) {
  8479. options.byweekday = [
  8480. src.MO,
  8481. src.TU,
  8482. src.WE,
  8483. src.TH,
  8484. src.FR
  8485. ];
  8486. }
  8487. }
  8488. else if (ttr.symbol === 'week(s)') {
  8489. ttr.nextSymbol();
  8490. var n = ttr.acceptNumber();
  8491. if (!n) {
  8492. throw new Error('Unexpected symbol ' + ttr.symbol + ', expected week number');
  8493. }
  8494. options.byweekno = [parseInt(n[0], 10)];
  8495. while (ttr.accept('comma')) {
  8496. n = ttr.acceptNumber();
  8497. if (!n) {
  8498. throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
  8499. }
  8500. options.byweekno.push(parseInt(n[0], 10));
  8501. }
  8502. }
  8503. else if (m) {
  8504. ttr.nextSymbol();
  8505. if (!options.bymonth)
  8506. options.bymonth = [];
  8507. // @ts-ignore
  8508. options.bymonth.push(m);
  8509. }
  8510. else {
  8511. return;
  8512. }
  8513. } while (ttr.accept('comma') || ttr.accept('the') || ttr.accept('on'));
  8514. }
  8515. function AT() {
  8516. var at = ttr.accept('at');
  8517. if (!at)
  8518. return;
  8519. do {
  8520. var n = ttr.acceptNumber();
  8521. if (!n) {
  8522. throw new Error('Unexpected symbol ' + ttr.symbol + ', expected hour');
  8523. }
  8524. options.byhour = [parseInt(n[0], 10)];
  8525. while (ttr.accept('comma')) {
  8526. n = ttr.acceptNumber();
  8527. if (!n) {
  8528. throw new Error('Unexpected symbol ' + ttr.symbol + '; expected hour');
  8529. }
  8530. options.byhour.push(parseInt(n[0], 10));
  8531. }
  8532. } while (ttr.accept('comma') || ttr.accept('at'));
  8533. }
  8534. function decodeM() {
  8535. switch (ttr.symbol) {
  8536. case 'january':
  8537. return 1;
  8538. case 'february':
  8539. return 2;
  8540. case 'march':
  8541. return 3;
  8542. case 'april':
  8543. return 4;
  8544. case 'may':
  8545. return 5;
  8546. case 'june':
  8547. return 6;
  8548. case 'july':
  8549. return 7;
  8550. case 'august':
  8551. return 8;
  8552. case 'september':
  8553. return 9;
  8554. case 'october':
  8555. return 10;
  8556. case 'november':
  8557. return 11;
  8558. case 'december':
  8559. return 12;
  8560. default:
  8561. return false;
  8562. }
  8563. }
  8564. function decodeWKD() {
  8565. switch (ttr.symbol) {
  8566. case 'monday':
  8567. case 'tuesday':
  8568. case 'wednesday':
  8569. case 'thursday':
  8570. case 'friday':
  8571. case 'saturday':
  8572. case 'sunday':
  8573. return ttr.symbol.substr(0, 2).toUpperCase();
  8574. default:
  8575. return false;
  8576. }
  8577. }
  8578. function decodeNTH() {
  8579. switch (ttr.symbol) {
  8580. case 'last':
  8581. ttr.nextSymbol();
  8582. return -1;
  8583. case 'first':
  8584. ttr.nextSymbol();
  8585. return 1;
  8586. case 'second':
  8587. ttr.nextSymbol();
  8588. return ttr.accept('last') ? -2 : 2;
  8589. case 'third':
  8590. ttr.nextSymbol();
  8591. return ttr.accept('last') ? -3 : 3;
  8592. case 'nth':
  8593. var v = parseInt(ttr.value[1], 10);
  8594. if (v < -366 || v > 366)
  8595. throw new Error('Nth out of range: ' + v);
  8596. ttr.nextSymbol();
  8597. return ttr.accept('last') ? -v : v;
  8598. default:
  8599. return false;
  8600. }
  8601. }
  8602. function MDAYs() {
  8603. ttr.accept('on');
  8604. ttr.accept('the');
  8605. var nth = decodeNTH();
  8606. if (!nth)
  8607. return;
  8608. options.bymonthday = [nth];
  8609. ttr.nextSymbol();
  8610. while (ttr.accept('comma')) {
  8611. nth = decodeNTH();
  8612. if (!nth) {
  8613. throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
  8614. }
  8615. options.bymonthday.push(nth);
  8616. ttr.nextSymbol();
  8617. }
  8618. }
  8619. function F() {
  8620. if (ttr.symbol === 'until') {
  8621. var date = Date.parse(ttr.text);
  8622. if (!date)
  8623. throw new Error('Cannot parse until date:' + ttr.text);
  8624. options.until = new Date(date);
  8625. }
  8626. else if (ttr.accept('for')) {
  8627. options.count = parseInt(ttr.value[0], 10);
  8628. ttr.expect('number');
  8629. // ttr.expect('times')
  8630. }
  8631. }
  8632. }
  8633. // CONCATENATED MODULE: ./src/types.ts
  8634. var Frequency;
  8635. (function (Frequency) {
  8636. Frequency[Frequency["YEARLY"] = 0] = "YEARLY";
  8637. Frequency[Frequency["MONTHLY"] = 1] = "MONTHLY";
  8638. Frequency[Frequency["WEEKLY"] = 2] = "WEEKLY";
  8639. Frequency[Frequency["DAILY"] = 3] = "DAILY";
  8640. Frequency[Frequency["HOURLY"] = 4] = "HOURLY";
  8641. Frequency[Frequency["MINUTELY"] = 5] = "MINUTELY";
  8642. Frequency[Frequency["SECONDLY"] = 6] = "SECONDLY";
  8643. })(Frequency || (Frequency = {}));
  8644. function freqIsDailyOrGreater(freq) {
  8645. return freq < Frequency.HOURLY;
  8646. }
  8647. // CONCATENATED MODULE: ./src/nlp/index.ts
  8648. /*!
  8649. * rrule.js - Library for working with recurrence rules for calendar dates.
  8650. * https://github.com/jakubroztocil/rrule
  8651. *
  8652. * Copyright 2010, Jakub Roztocil and Lars Schoning
  8653. * Licenced under the BSD licence.
  8654. * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
  8655. *
  8656. */
  8657. /**
  8658. *
  8659. * Implementation of RRule.fromText() and RRule::toText().
  8660. *
  8661. *
  8662. * On the client side, this file needs to be included
  8663. * when those functions are used.
  8664. *
  8665. */
  8666. // =============================================================================
  8667. // fromText
  8668. // =============================================================================
  8669. /**
  8670. * Will be able to convert some of the below described rules from
  8671. * text format to a rule object.
  8672. *
  8673. *
  8674. * RULES
  8675. *
  8676. * Every ([n])
  8677. * day(s)
  8678. * | [weekday], ..., (and) [weekday]
  8679. * | weekday(s)
  8680. * | week(s)
  8681. * | month(s)
  8682. * | [month], ..., (and) [month]
  8683. * | year(s)
  8684. *
  8685. *
  8686. * Plus 0, 1, or multiple of these:
  8687. *
  8688. * on [weekday], ..., (or) [weekday] the [monthday], [monthday], ... (or) [monthday]
  8689. *
  8690. * on [weekday], ..., (and) [weekday]
  8691. *
  8692. * on the [monthday], [monthday], ... (and) [monthday] (day of the month)
  8693. *
  8694. * on the [nth-weekday], ..., (and) [nth-weekday] (of the month/year)
  8695. *
  8696. *
  8697. * Plus 0 or 1 of these:
  8698. *
  8699. * for [n] time(s)
  8700. *
  8701. * until [date]
  8702. *
  8703. * Plus (.)
  8704. *
  8705. *
  8706. * Definitely no supported for parsing:
  8707. *
  8708. * (for year):
  8709. * in week(s) [n], ..., (and) [n]
  8710. *
  8711. * on the [yearday], ..., (and) [n] day of the year
  8712. * on day [yearday], ..., (and) [n]
  8713. *
  8714. *
  8715. * NON-TERMINALS
  8716. *
  8717. * [n]: 1, 2 ..., one, two, three ..
  8718. * [month]: January, February, March, April, May, ... December
  8719. * [weekday]: Monday, ... Sunday
  8720. * [nth-weekday]: first [weekday], 2nd [weekday], ... last [weekday], ...
  8721. * [monthday]: first, 1., 2., 1st, 2nd, second, ... 31st, last day, 2nd last day, ..
  8722. * [date]:
  8723. * [month] (0-31(,) ([year])),
  8724. * (the) 0-31.(1-12.([year])),
  8725. * (the) 0-31/(1-12/([year])),
  8726. * [weekday]
  8727. *
  8728. * [year]: 0000, 0001, ... 01, 02, ..
  8729. *
  8730. * Definitely not supported for parsing:
  8731. *
  8732. * [yearday]: first, 1., 2., 1st, 2nd, second, ... 366th, last day, 2nd last day, ..
  8733. *
  8734. * @param {String} text
  8735. * @return {Object, Boolean} the rule, or null.
  8736. */
  8737. var fromText = function (text, language) {
  8738. if (language === void 0) { language = i18n; }
  8739. return new src(parseText(text, language) || undefined);
  8740. };
  8741. var common = [
  8742. 'count',
  8743. 'until',
  8744. 'interval',
  8745. 'byweekday',
  8746. 'bymonthday',
  8747. 'bymonth'
  8748. ];
  8749. totext.IMPLEMENTED = [];
  8750. totext.IMPLEMENTED[Frequency.HOURLY] = common;
  8751. totext.IMPLEMENTED[Frequency.MINUTELY] = common;
  8752. totext.IMPLEMENTED[Frequency.DAILY] = ['byhour'].concat(common);
  8753. totext.IMPLEMENTED[Frequency.WEEKLY] = common;
  8754. totext.IMPLEMENTED[Frequency.MONTHLY] = common;
  8755. totext.IMPLEMENTED[Frequency.YEARLY] = ['byweekno', 'byyearday'].concat(common);
  8756. // =============================================================================
  8757. // Export
  8758. // =============================================================================
  8759. var toText = function (rrule, gettext, language, dateFormatter) {
  8760. return new totext(rrule, gettext, language, dateFormatter).toString();
  8761. };
  8762. var isFullyConvertible = totext.isFullyConvertible;
  8763. // CONCATENATED MODULE: ./src/datetime.ts
  8764. var Time = /** @class */ (function () {
  8765. function Time(hour, minute, second, millisecond) {
  8766. this.hour = hour;
  8767. this.minute = minute;
  8768. this.second = second;
  8769. this.millisecond = millisecond || 0;
  8770. }
  8771. Time.prototype.getHours = function () {
  8772. return this.hour;
  8773. };
  8774. Time.prototype.getMinutes = function () {
  8775. return this.minute;
  8776. };
  8777. Time.prototype.getSeconds = function () {
  8778. return this.second;
  8779. };
  8780. Time.prototype.getMilliseconds = function () {
  8781. return this.millisecond;
  8782. };
  8783. Time.prototype.getTime = function () {
  8784. return ((this.hour * 60 * 60 + this.minute * 60 + this.second) * 1000 +
  8785. this.millisecond);
  8786. };
  8787. return Time;
  8788. }());
  8789. var datetime_DateTime = /** @class */ (function (_super) {
  8790. __extends(DateTime, _super);
  8791. function DateTime(year, month, day, hour, minute, second, millisecond) {
  8792. var _this = _super.call(this, hour, minute, second, millisecond) || this;
  8793. _this.year = year;
  8794. _this.month = month;
  8795. _this.day = day;
  8796. return _this;
  8797. }
  8798. DateTime.fromDate = function (date) {
  8799. return new this(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.valueOf() % 1000);
  8800. };
  8801. DateTime.prototype.getWeekday = function () {
  8802. return dateutil_dateutil.getWeekday(new Date(this.getTime()));
  8803. };
  8804. DateTime.prototype.getTime = function () {
  8805. return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)).getTime();
  8806. };
  8807. DateTime.prototype.getDay = function () {
  8808. return this.day;
  8809. };
  8810. DateTime.prototype.getMonth = function () {
  8811. return this.month;
  8812. };
  8813. DateTime.prototype.getYear = function () {
  8814. return this.year;
  8815. };
  8816. DateTime.prototype.addYears = function (years) {
  8817. this.year += years;
  8818. };
  8819. DateTime.prototype.addMonths = function (months) {
  8820. this.month += months;
  8821. if (this.month > 12) {
  8822. var yearDiv = Math.floor(this.month / 12);
  8823. var monthMod = pymod(this.month, 12);
  8824. this.month = monthMod;
  8825. this.year += yearDiv;
  8826. if (this.month === 0) {
  8827. this.month = 12;
  8828. --this.year;
  8829. }
  8830. }
  8831. };
  8832. DateTime.prototype.addWeekly = function (days, wkst) {
  8833. if (wkst > this.getWeekday()) {
  8834. this.day += -(this.getWeekday() + 1 + (6 - wkst)) + days * 7;
  8835. }
  8836. else {
  8837. this.day += -(this.getWeekday() - wkst) + days * 7;
  8838. }
  8839. this.fixDay();
  8840. };
  8841. DateTime.prototype.addDaily = function (days) {
  8842. this.day += days;
  8843. this.fixDay();
  8844. };
  8845. DateTime.prototype.addHours = function (hours, filtered, byhour) {
  8846. if (filtered) {
  8847. // Jump to one iteration before next day
  8848. this.hour += Math.floor((23 - this.hour) / hours) * hours;
  8849. }
  8850. while (true) {
  8851. this.hour += hours;
  8852. var _a = divmod(this.hour, 24), dayDiv = _a.div, hourMod = _a.mod;
  8853. if (dayDiv) {
  8854. this.hour = hourMod;
  8855. this.addDaily(dayDiv);
  8856. }
  8857. if (empty(byhour) || includes(byhour, this.hour))
  8858. break;
  8859. }
  8860. };
  8861. DateTime.prototype.addMinutes = function (minutes, filtered, byhour, byminute) {
  8862. if (filtered) {
  8863. // Jump to one iteration before next day
  8864. this.minute +=
  8865. Math.floor((1439 - (this.hour * 60 + this.minute)) / minutes) * minutes;
  8866. }
  8867. while (true) {
  8868. this.minute += minutes;
  8869. var _a = divmod(this.minute, 60), hourDiv = _a.div, minuteMod = _a.mod;
  8870. if (hourDiv) {
  8871. this.minute = minuteMod;
  8872. this.addHours(hourDiv, false, byhour);
  8873. }
  8874. if ((empty(byhour) || includes(byhour, this.hour)) &&
  8875. (empty(byminute) || includes(byminute, this.minute))) {
  8876. break;
  8877. }
  8878. }
  8879. };
  8880. DateTime.prototype.addSeconds = function (seconds, filtered, byhour, byminute, bysecond) {
  8881. if (filtered) {
  8882. // Jump to one iteration before next day
  8883. this.second +=
  8884. Math.floor((86399 - (this.hour * 3600 + this.minute * 60 + this.second)) / seconds) * seconds;
  8885. }
  8886. while (true) {
  8887. this.second += seconds;
  8888. var _a = divmod(this.second, 60), minuteDiv = _a.div, secondMod = _a.mod;
  8889. if (minuteDiv) {
  8890. this.second = secondMod;
  8891. this.addMinutes(minuteDiv, false, byhour, byminute);
  8892. }
  8893. if ((empty(byhour) || includes(byhour, this.hour)) &&
  8894. (empty(byminute) || includes(byminute, this.minute)) &&
  8895. (empty(bysecond) || includes(bysecond, this.second))) {
  8896. break;
  8897. }
  8898. }
  8899. };
  8900. DateTime.prototype.fixDay = function () {
  8901. if (this.day <= 28) {
  8902. return;
  8903. }
  8904. var daysinmonth = dateutil_dateutil.monthRange(this.year, this.month - 1)[1];
  8905. if (this.day <= daysinmonth) {
  8906. return;
  8907. }
  8908. while (this.day > daysinmonth) {
  8909. this.day -= daysinmonth;
  8910. ++this.month;
  8911. if (this.month === 13) {
  8912. this.month = 1;
  8913. ++this.year;
  8914. if (this.year > dateutil_dateutil.MAXYEAR) {
  8915. return;
  8916. }
  8917. }
  8918. daysinmonth = dateutil_dateutil.monthRange(this.year, this.month - 1)[1];
  8919. }
  8920. };
  8921. DateTime.prototype.add = function (options, filtered) {
  8922. var freq = options.freq, interval = options.interval, wkst = options.wkst, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
  8923. switch (freq) {
  8924. case Frequency.YEARLY: return this.addYears(interval);
  8925. case Frequency.MONTHLY: return this.addMonths(interval);
  8926. case Frequency.WEEKLY: return this.addWeekly(interval, wkst);
  8927. case Frequency.DAILY: return this.addDaily(interval);
  8928. case Frequency.HOURLY: return this.addHours(interval, filtered, byhour);
  8929. case Frequency.MINUTELY: return this.addMinutes(interval, filtered, byhour, byminute);
  8930. case Frequency.SECONDLY: return this.addSeconds(interval, filtered, byhour, byminute, bysecond);
  8931. }
  8932. };
  8933. return DateTime;
  8934. }(Time));
  8935. // CONCATENATED MODULE: ./src/parseoptions.ts
  8936. function initializeOptions(options) {
  8937. var invalid = [];
  8938. var keys = Object.keys(options);
  8939. // Shallow copy for options and origOptions and check for invalid
  8940. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  8941. var key = keys_1[_i];
  8942. if (!includes(rrule_defaultKeys, key))
  8943. invalid.push(key);
  8944. if (src_dateutil.isDate(options[key]) && !src_dateutil.isValidDate(options[key]))
  8945. invalid.push(key);
  8946. }
  8947. if (invalid.length) {
  8948. throw new Error('Invalid options: ' + invalid.join(', '));
  8949. }
  8950. return __assign({}, options);
  8951. }
  8952. function parseOptions(options) {
  8953. var opts = __assign(__assign({}, DEFAULT_OPTIONS), initializeOptions(options));
  8954. if (isPresent(opts.byeaster))
  8955. opts.freq = src_rrule.YEARLY;
  8956. if (!(isPresent(opts.freq) && src_rrule.FREQUENCIES[opts.freq])) {
  8957. throw new Error("Invalid frequency: " + opts.freq + " " + options.freq);
  8958. }
  8959. if (!opts.dtstart)
  8960. opts.dtstart = new Date(new Date().setMilliseconds(0));
  8961. if (!isPresent(opts.wkst)) {
  8962. opts.wkst = src_rrule.MO.weekday;
  8963. }
  8964. else if (isNumber(opts.wkst)) {
  8965. // cool, just keep it like that
  8966. }
  8967. else {
  8968. opts.wkst = opts.wkst.weekday;
  8969. }
  8970. if (isPresent(opts.bysetpos)) {
  8971. if (isNumber(opts.bysetpos))
  8972. opts.bysetpos = [opts.bysetpos];
  8973. for (var i = 0; i < opts.bysetpos.length; i++) {
  8974. var v = opts.bysetpos[i];
  8975. if (v === 0 || !(v >= -366 && v <= 366)) {
  8976. throw new Error('bysetpos must be between 1 and 366,' + ' or between -366 and -1');
  8977. }
  8978. }
  8979. }
  8980. if (!(Boolean(opts.byweekno) ||
  8981. notEmpty(opts.byweekno) ||
  8982. notEmpty(opts.byyearday) ||
  8983. Boolean(opts.bymonthday) ||
  8984. notEmpty(opts.bymonthday) ||
  8985. isPresent(opts.byweekday) ||
  8986. isPresent(opts.byeaster))) {
  8987. switch (opts.freq) {
  8988. case src_rrule.YEARLY:
  8989. if (!opts.bymonth)
  8990. opts.bymonth = opts.dtstart.getUTCMonth() + 1;
  8991. opts.bymonthday = opts.dtstart.getUTCDate();
  8992. break;
  8993. case src_rrule.MONTHLY:
  8994. opts.bymonthday = opts.dtstart.getUTCDate();
  8995. break;
  8996. case src_rrule.WEEKLY:
  8997. opts.byweekday = [src_dateutil.getWeekday(opts.dtstart)];
  8998. break;
  8999. }
  9000. }
  9001. // bymonth
  9002. if (isPresent(opts.bymonth) && !isArray(opts.bymonth)) {
  9003. opts.bymonth = [opts.bymonth];
  9004. }
  9005. // byyearday
  9006. if (isPresent(opts.byyearday) &&
  9007. !isArray(opts.byyearday) &&
  9008. isNumber(opts.byyearday)) {
  9009. opts.byyearday = [opts.byyearday];
  9010. }
  9011. // bymonthday
  9012. if (!isPresent(opts.bymonthday)) {
  9013. opts.bymonthday = [];
  9014. opts.bynmonthday = [];
  9015. }
  9016. else if (isArray(opts.bymonthday)) {
  9017. var bymonthday = [];
  9018. var bynmonthday = [];
  9019. for (var i = 0; i < opts.bymonthday.length; i++) {
  9020. var v = opts.bymonthday[i];
  9021. if (v > 0) {
  9022. bymonthday.push(v);
  9023. }
  9024. else if (v < 0) {
  9025. bynmonthday.push(v);
  9026. }
  9027. }
  9028. opts.bymonthday = bymonthday;
  9029. opts.bynmonthday = bynmonthday;
  9030. }
  9031. else if (opts.bymonthday < 0) {
  9032. opts.bynmonthday = [opts.bymonthday];
  9033. opts.bymonthday = [];
  9034. }
  9035. else {
  9036. opts.bynmonthday = [];
  9037. opts.bymonthday = [opts.bymonthday];
  9038. }
  9039. // byweekno
  9040. if (isPresent(opts.byweekno) && !isArray(opts.byweekno)) {
  9041. opts.byweekno = [opts.byweekno];
  9042. }
  9043. // byweekday / bynweekday
  9044. if (!isPresent(opts.byweekday)) {
  9045. opts.bynweekday = null;
  9046. }
  9047. else if (isNumber(opts.byweekday)) {
  9048. opts.byweekday = [opts.byweekday];
  9049. opts.bynweekday = null;
  9050. }
  9051. else if (isWeekdayStr(opts.byweekday)) {
  9052. opts.byweekday = [Weekday.fromStr(opts.byweekday).weekday];
  9053. opts.bynweekday = null;
  9054. }
  9055. else if (opts.byweekday instanceof Weekday) {
  9056. if (!opts.byweekday.n || opts.freq > src_rrule.MONTHLY) {
  9057. opts.byweekday = [opts.byweekday.weekday];
  9058. opts.bynweekday = null;
  9059. }
  9060. else {
  9061. opts.bynweekday = [[opts.byweekday.weekday, opts.byweekday.n]];
  9062. opts.byweekday = null;
  9063. }
  9064. }
  9065. else {
  9066. var byweekday = [];
  9067. var bynweekday = [];
  9068. for (var i = 0; i < opts.byweekday.length; i++) {
  9069. var wday = opts.byweekday[i];
  9070. if (isNumber(wday)) {
  9071. byweekday.push(wday);
  9072. continue;
  9073. }
  9074. else if (isWeekdayStr(wday)) {
  9075. byweekday.push(Weekday.fromStr(wday).weekday);
  9076. continue;
  9077. }
  9078. if (!wday.n || opts.freq > src_rrule.MONTHLY) {
  9079. byweekday.push(wday.weekday);
  9080. }
  9081. else {
  9082. bynweekday.push([wday.weekday, wday.n]);
  9083. }
  9084. }
  9085. opts.byweekday = notEmpty(byweekday) ? byweekday : null;
  9086. opts.bynweekday = notEmpty(bynweekday) ? bynweekday : null;
  9087. }
  9088. // byhour
  9089. if (!isPresent(opts.byhour)) {
  9090. opts.byhour =
  9091. opts.freq < src_rrule.HOURLY ? [opts.dtstart.getUTCHours()] : null;
  9092. }
  9093. else if (isNumber(opts.byhour)) {
  9094. opts.byhour = [opts.byhour];
  9095. }
  9096. // byminute
  9097. if (!isPresent(opts.byminute)) {
  9098. opts.byminute =
  9099. opts.freq < src_rrule.MINUTELY ? [opts.dtstart.getUTCMinutes()] : null;
  9100. }
  9101. else if (isNumber(opts.byminute)) {
  9102. opts.byminute = [opts.byminute];
  9103. }
  9104. // bysecond
  9105. if (!isPresent(opts.bysecond)) {
  9106. opts.bysecond =
  9107. opts.freq < src_rrule.SECONDLY ? [opts.dtstart.getUTCSeconds()] : null;
  9108. }
  9109. else if (isNumber(opts.bysecond)) {
  9110. opts.bysecond = [opts.bysecond];
  9111. }
  9112. return { parsedOptions: opts };
  9113. }
  9114. function buildTimeset(opts) {
  9115. var millisecondModulo = opts.dtstart.getTime() % 1000;
  9116. if (!freqIsDailyOrGreater(opts.freq)) {
  9117. return [];
  9118. }
  9119. var timeset = [];
  9120. opts.byhour.forEach(function (hour) {
  9121. opts.byminute.forEach(function (minute) {
  9122. opts.bysecond.forEach(function (second) {
  9123. timeset.push(new Time(hour, minute, second, millisecondModulo));
  9124. });
  9125. });
  9126. });
  9127. return timeset;
  9128. }
  9129. // CONCATENATED MODULE: ./src/parsestring.ts
  9130. function parseString(rfcString) {
  9131. var options = rfcString.split('\n').map(parseLine).filter(function (x) { return x !== null; });
  9132. return __assign(__assign({}, options[0]), options[1]);
  9133. }
  9134. function parseDtstart(line) {
  9135. var options = {};
  9136. var dtstartWithZone = /DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(line);
  9137. if (!dtstartWithZone) {
  9138. return options;
  9139. }
  9140. var _ = dtstartWithZone[0], tzid = dtstartWithZone[1], dtstart = dtstartWithZone[2];
  9141. if (tzid) {
  9142. options.tzid = tzid;
  9143. }
  9144. options.dtstart = src_dateutil.untilStringToDate(dtstart);
  9145. return options;
  9146. }
  9147. function parseLine(rfcString) {
  9148. rfcString = rfcString.replace(/^\s+|\s+$/, '');
  9149. if (!rfcString.length)
  9150. return null;
  9151. var header = /^([A-Z]+?)[:;]/.exec(rfcString.toUpperCase());
  9152. if (!header) {
  9153. return parseRrule(rfcString);
  9154. }
  9155. var _ = header[0], key = header[1];
  9156. switch (key.toUpperCase()) {
  9157. case 'RRULE':
  9158. case 'EXRULE':
  9159. return parseRrule(rfcString);
  9160. case 'DTSTART':
  9161. return parseDtstart(rfcString);
  9162. default:
  9163. throw new Error("Unsupported RFC prop " + key + " in " + rfcString);
  9164. }
  9165. }
  9166. function parseRrule(line) {
  9167. var strippedLine = line.replace(/^RRULE:/i, '');
  9168. var options = parseDtstart(strippedLine);
  9169. var attrs = line.replace(/^(?:RRULE|EXRULE):/i, '').split(';');
  9170. attrs.forEach(function (attr) {
  9171. var _a = attr.split('='), key = _a[0], value = _a[1];
  9172. switch (key.toUpperCase()) {
  9173. case 'FREQ':
  9174. options.freq = Frequency[value.toUpperCase()];
  9175. break;
  9176. case 'WKST':
  9177. options.wkst = Days[value.toUpperCase()];
  9178. break;
  9179. case 'COUNT':
  9180. case 'INTERVAL':
  9181. case 'BYSETPOS':
  9182. case 'BYMONTH':
  9183. case 'BYMONTHDAY':
  9184. case 'BYYEARDAY':
  9185. case 'BYWEEKNO':
  9186. case 'BYHOUR':
  9187. case 'BYMINUTE':
  9188. case 'BYSECOND':
  9189. var num = parseNumber(value);
  9190. var optionKey = key.toLowerCase();
  9191. // @ts-ignore
  9192. options[optionKey] = num;
  9193. break;
  9194. case 'BYWEEKDAY':
  9195. case 'BYDAY':
  9196. options.byweekday = parseWeekday(value);
  9197. break;
  9198. case 'DTSTART':
  9199. case 'TZID':
  9200. // for backwards compatibility
  9201. var dtstart = parseDtstart(line);
  9202. options.tzid = dtstart.tzid;
  9203. options.dtstart = dtstart.dtstart;
  9204. break;
  9205. case 'UNTIL':
  9206. options.until = src_dateutil.untilStringToDate(value);
  9207. break;
  9208. case 'BYEASTER':
  9209. options.byeaster = Number(value);
  9210. break;
  9211. default:
  9212. throw new Error("Unknown RRULE property '" + key + "'");
  9213. }
  9214. });
  9215. return options;
  9216. }
  9217. function parseNumber(value) {
  9218. if (value.indexOf(',') !== -1) {
  9219. var values = value.split(',');
  9220. return values.map(parseIndividualNumber);
  9221. }
  9222. return parseIndividualNumber(value);
  9223. }
  9224. function parseIndividualNumber(value) {
  9225. if (/^[+-]?\d+$/.test(value)) {
  9226. return Number(value);
  9227. }
  9228. return value;
  9229. }
  9230. function parseWeekday(value) {
  9231. var days = value.split(',');
  9232. return days.map(function (day) {
  9233. if (day.length === 2) {
  9234. // MO, TU, ...
  9235. return Days[day]; // wday instanceof Weekday
  9236. }
  9237. // -1MO, +3FR, 1SO, 13TU ...
  9238. var parts = day.match(/^([+-]?\d{1,2})([A-Z]{2})$/);
  9239. var n = Number(parts[1]);
  9240. var wdaypart = parts[2];
  9241. var wday = Days[wdaypart].weekday;
  9242. return new Weekday(wday, n);
  9243. });
  9244. }
  9245. // EXTERNAL MODULE: ./node_modules/luxon/build/cjs-browser/luxon.js
  9246. var luxon = __webpack_require__(0);
  9247. // CONCATENATED MODULE: ./src/datewithzone.ts
  9248. var datewithzone_DateWithZone = /** @class */ (function () {
  9249. function DateWithZone(date, tzid) {
  9250. this.date = date;
  9251. this.tzid = tzid;
  9252. }
  9253. Object.defineProperty(DateWithZone.prototype, "isUTC", {
  9254. get: function () {
  9255. return !this.tzid || this.tzid.toUpperCase() === 'UTC';
  9256. },
  9257. enumerable: true,
  9258. configurable: true
  9259. });
  9260. DateWithZone.prototype.toString = function () {
  9261. var datestr = src_dateutil.timeToUntilString(this.date.getTime(), this.isUTC);
  9262. if (!this.isUTC) {
  9263. return ";TZID=" + this.tzid + ":" + datestr;
  9264. }
  9265. return ":" + datestr;
  9266. };
  9267. DateWithZone.prototype.getTime = function () {
  9268. return this.date.getTime();
  9269. };
  9270. DateWithZone.prototype.rezonedDate = function () {
  9271. if (this.isUTC) {
  9272. return this.date;
  9273. }
  9274. try {
  9275. var datetime = luxon["DateTime"]
  9276. .fromJSDate(this.date);
  9277. var rezoned = datetime.setZone(this.tzid, { keepLocalTime: true });
  9278. return rezoned.toJSDate();
  9279. }
  9280. catch (e) {
  9281. if (e instanceof TypeError) {
  9282. console.error('Using TZID without Luxon available is unsupported. Returned times are in UTC, not the requested time zone');
  9283. }
  9284. return this.date;
  9285. }
  9286. };
  9287. return DateWithZone;
  9288. }());
  9289. // CONCATENATED MODULE: ./src/optionstostring.ts
  9290. function optionsToString(options) {
  9291. var rrule = [];
  9292. var dtstart = '';
  9293. var keys = Object.keys(options);
  9294. var defaultKeys = Object.keys(DEFAULT_OPTIONS);
  9295. for (var i = 0; i < keys.length; i++) {
  9296. if (keys[i] === 'tzid')
  9297. continue;
  9298. if (!includes(defaultKeys, keys[i]))
  9299. continue;
  9300. var key = keys[i].toUpperCase();
  9301. var value = options[keys[i]];
  9302. var outValue = '';
  9303. if (!isPresent(value) || (isArray(value) && !value.length))
  9304. continue;
  9305. switch (key) {
  9306. case 'FREQ':
  9307. outValue = src_rrule.FREQUENCIES[options.freq];
  9308. break;
  9309. case 'WKST':
  9310. if (isNumber(value)) {
  9311. outValue = new Weekday(value).toString();
  9312. }
  9313. else {
  9314. outValue = value.toString();
  9315. }
  9316. break;
  9317. case 'BYWEEKDAY':
  9318. /*
  9319. NOTE: BYWEEKDAY is a special case.
  9320. RRule() deconstructs the rule.options.byweekday array
  9321. into an array of Weekday arguments.
  9322. On the other hand, rule.origOptions is an array of Weekdays.
  9323. We need to handle both cases here.
  9324. It might be worth change RRule to keep the Weekdays.
  9325. Also, BYWEEKDAY (used by RRule) vs. BYDAY (RFC)
  9326. */
  9327. key = 'BYDAY';
  9328. outValue = toArray(value).map(function (wday) {
  9329. if (wday instanceof Weekday) {
  9330. return wday;
  9331. }
  9332. if (isArray(wday)) {
  9333. return new Weekday(wday[0], wday[1]);
  9334. }
  9335. return new Weekday(wday);
  9336. }).toString();
  9337. break;
  9338. case 'DTSTART':
  9339. dtstart = buildDtstart(value, options.tzid);
  9340. break;
  9341. case 'UNTIL':
  9342. outValue = src_dateutil.timeToUntilString(value, !options.tzid);
  9343. break;
  9344. default:
  9345. if (isArray(value)) {
  9346. var strValues = [];
  9347. for (var j = 0; j < value.length; j++) {
  9348. strValues[j] = String(value[j]);
  9349. }
  9350. outValue = strValues.toString();
  9351. }
  9352. else {
  9353. outValue = String(value);
  9354. }
  9355. }
  9356. if (outValue) {
  9357. rrule.push([key, outValue]);
  9358. }
  9359. }
  9360. var rules = rrule.map(function (_a) {
  9361. var key = _a[0], value = _a[1];
  9362. return key + "=" + value.toString();
  9363. }).join(';');
  9364. var ruleString = '';
  9365. if (rules !== '') {
  9366. ruleString = "RRULE:" + rules;
  9367. }
  9368. return [dtstart, ruleString].filter(function (x) { return !!x; }).join('\n');
  9369. }
  9370. function buildDtstart(dtstart, tzid) {
  9371. if (!dtstart) {
  9372. return '';
  9373. }
  9374. return 'DTSTART' + new datewithzone_DateWithZone(new Date(dtstart), tzid).toString();
  9375. }
  9376. // CONCATENATED MODULE: ./src/cache.ts
  9377. var cache_Cache = /** @class */ (function () {
  9378. function Cache() {
  9379. this.all = false;
  9380. this.before = [];
  9381. this.after = [];
  9382. this.between = [];
  9383. }
  9384. /**
  9385. * @param {String} what - all/before/after/between
  9386. * @param {Array,Date} value - an array of dates, one date, or null
  9387. * @param {Object?} args - _iter arguments
  9388. */
  9389. Cache.prototype._cacheAdd = function (what, value, args) {
  9390. if (value) {
  9391. value =
  9392. value instanceof Date
  9393. ? src_dateutil.clone(value)
  9394. : src_dateutil.cloneDates(value);
  9395. }
  9396. if (what === 'all') {
  9397. this.all = value;
  9398. }
  9399. else {
  9400. args._value = value;
  9401. this[what].push(args);
  9402. }
  9403. };
  9404. /**
  9405. * @return false - not in the cache
  9406. * null - cached, but zero occurrences (before/after)
  9407. * Date - cached (before/after)
  9408. * [] - cached, but zero occurrences (all/between)
  9409. * [Date1, DateN] - cached (all/between)
  9410. */
  9411. Cache.prototype._cacheGet = function (what, args) {
  9412. var cached = false;
  9413. var argsKeys = args ? Object.keys(args) : [];
  9414. var findCacheDiff = function (item) {
  9415. for (var i = 0; i < argsKeys.length; i++) {
  9416. var key = argsKeys[i];
  9417. if (String(args[key]) !== String(item[key])) {
  9418. return true;
  9419. }
  9420. }
  9421. return false;
  9422. };
  9423. var cachedObject = this[what];
  9424. if (what === 'all') {
  9425. cached = this.all;
  9426. }
  9427. else if (isArray(cachedObject)) {
  9428. // Let's see whether we've already called the
  9429. // 'what' method with the same 'args'
  9430. for (var i = 0; i < cachedObject.length; i++) {
  9431. var item = cachedObject[i];
  9432. if (argsKeys.length && findCacheDiff(item))
  9433. continue;
  9434. cached = item._value;
  9435. break;
  9436. }
  9437. }
  9438. if (!cached && this.all) {
  9439. // Not in the cache, but we already know all the occurrences,
  9440. // so we can find the correct dates from the cached ones.
  9441. var iterResult = new iterresult(what, args);
  9442. for (var i = 0; i < this.all.length; i++) {
  9443. if (!iterResult.accept(this.all[i]))
  9444. break;
  9445. }
  9446. cached = iterResult.getValue();
  9447. this._cacheAdd(what, cached, args);
  9448. }
  9449. return isArray(cached)
  9450. ? src_dateutil.cloneDates(cached)
  9451. : cached instanceof Date
  9452. ? src_dateutil.clone(cached)
  9453. : cached;
  9454. };
  9455. return Cache;
  9456. }());
  9457. // CONCATENATED MODULE: ./src/masks.ts
  9458. // =============================================================================
  9459. // Date masks
  9460. // =============================================================================
  9461. // Every mask is 7 days longer to handle cross-year weekly periods.
  9462. var M365MASK = __spreadArrays(repeat(1, 31), repeat(2, 28), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
  9463. var M366MASK = __spreadArrays(repeat(1, 31), repeat(2, 29), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
  9464. var M28 = range(1, 29);
  9465. var M29 = range(1, 30);
  9466. var M30 = range(1, 31);
  9467. var M31 = range(1, 32);
  9468. var MDAY366MASK = __spreadArrays(M31, M29, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
  9469. var MDAY365MASK = __spreadArrays(M31, M28, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
  9470. var NM28 = range(-28, 0);
  9471. var NM29 = range(-29, 0);
  9472. var NM30 = range(-30, 0);
  9473. var NM31 = range(-31, 0);
  9474. var NMDAY366MASK = __spreadArrays(NM31, NM29, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
  9475. var NMDAY365MASK = __spreadArrays(NM31, NM28, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
  9476. var M366RANGE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
  9477. var M365RANGE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
  9478. var WDAYMASK = (function () {
  9479. var wdaymask = [];
  9480. for (var i = 0; i < 55; i++)
  9481. wdaymask = wdaymask.concat(range(7));
  9482. return wdaymask;
  9483. })();
  9484. // CONCATENATED MODULE: ./src/iterinfo/yearinfo.ts
  9485. function rebuildYear(year, options) {
  9486. var firstyday = new Date(Date.UTC(year, 0, 1));
  9487. var yearlen = src_dateutil.isLeapYear(year) ? 366 : 365;
  9488. var nextyearlen = src_dateutil.isLeapYear(year + 1) ? 366 : 365;
  9489. var yearordinal = src_dateutil.toOrdinal(firstyday);
  9490. var yearweekday = src_dateutil.getWeekday(firstyday);
  9491. var result = __assign(__assign({ yearlen: yearlen,
  9492. nextyearlen: nextyearlen,
  9493. yearordinal: yearordinal,
  9494. yearweekday: yearweekday }, baseYearMasks(year)), { wnomask: null });
  9495. if (empty(options.byweekno)) {
  9496. return result;
  9497. }
  9498. result.wnomask = repeat(0, yearlen + 7);
  9499. var firstwkst;
  9500. var wyearlen;
  9501. var no1wkst = firstwkst = pymod(7 - yearweekday + options.wkst, 7);
  9502. if (no1wkst >= 4) {
  9503. no1wkst = 0;
  9504. // Number of days in the year, plus the days we got
  9505. // from last year.
  9506. wyearlen =
  9507. result.yearlen + pymod(yearweekday - options.wkst, 7);
  9508. }
  9509. else {
  9510. // Number of days in the year, minus the days we
  9511. // left in last year.
  9512. wyearlen = yearlen - no1wkst;
  9513. }
  9514. var div = Math.floor(wyearlen / 7);
  9515. var mod = pymod(wyearlen, 7);
  9516. var numweeks = Math.floor(div + mod / 4);
  9517. for (var j = 0; j < options.byweekno.length; j++) {
  9518. var n = options.byweekno[j];
  9519. if (n < 0) {
  9520. n += numweeks + 1;
  9521. }
  9522. if (!(n > 0 && n <= numweeks)) {
  9523. continue;
  9524. }
  9525. var i = void 0;
  9526. if (n > 1) {
  9527. i = no1wkst + (n - 1) * 7;
  9528. if (no1wkst !== firstwkst) {
  9529. i -= 7 - firstwkst;
  9530. }
  9531. }
  9532. else {
  9533. i = no1wkst;
  9534. }
  9535. for (var k = 0; k < 7; k++) {
  9536. result.wnomask[i] = 1;
  9537. i++;
  9538. if (result.wdaymask[i] === options.wkst)
  9539. break;
  9540. }
  9541. }
  9542. if (includes(options.byweekno, 1)) {
  9543. // Check week number 1 of next year as well
  9544. // orig-TODO : Check -numweeks for next year.
  9545. var i = no1wkst + numweeks * 7;
  9546. if (no1wkst !== firstwkst)
  9547. i -= 7 - firstwkst;
  9548. if (i < yearlen) {
  9549. // If week starts in next year, we
  9550. // don't care about it.
  9551. for (var j = 0; j < 7; j++) {
  9552. result.wnomask[i] = 1;
  9553. i += 1;
  9554. if (result.wdaymask[i] === options.wkst)
  9555. break;
  9556. }
  9557. }
  9558. }
  9559. if (no1wkst) {
  9560. // Check last week number of last year as
  9561. // well. If no1wkst is 0, either the year
  9562. // started on week start, or week number 1
  9563. // got days from last year, so there are no
  9564. // days from last year's last week number in
  9565. // this year.
  9566. var lnumweeks = void 0;
  9567. if (!includes(options.byweekno, -1)) {
  9568. var lyearweekday = src_dateutil.getWeekday(new Date(Date.UTC(year - 1, 0, 1)));
  9569. var lno1wkst = pymod(7 - lyearweekday.valueOf() + options.wkst, 7);
  9570. var lyearlen = src_dateutil.isLeapYear(year - 1) ? 366 : 365;
  9571. var weekst = void 0;
  9572. if (lno1wkst >= 4) {
  9573. lno1wkst = 0;
  9574. weekst = lyearlen + pymod(lyearweekday - options.wkst, 7);
  9575. }
  9576. else {
  9577. weekst = yearlen - no1wkst;
  9578. }
  9579. lnumweeks = Math.floor(52 + pymod(weekst, 7) / 4);
  9580. }
  9581. else {
  9582. lnumweeks = -1;
  9583. }
  9584. if (includes(options.byweekno, lnumweeks)) {
  9585. for (var i = 0; i < no1wkst; i++)
  9586. result.wnomask[i] = 1;
  9587. }
  9588. }
  9589. return result;
  9590. }
  9591. function baseYearMasks(year) {
  9592. var yearlen = src_dateutil.isLeapYear(year) ? 366 : 365;
  9593. var firstyday = new Date(Date.UTC(year, 0, 1));
  9594. var wday = src_dateutil.getWeekday(firstyday);
  9595. if (yearlen === 365) {
  9596. return {
  9597. mmask: M365MASK,
  9598. mdaymask: MDAY365MASK,
  9599. nmdaymask: NMDAY365MASK,
  9600. wdaymask: WDAYMASK.slice(wday),
  9601. mrange: M365RANGE
  9602. };
  9603. }
  9604. return {
  9605. mmask: M366MASK,
  9606. mdaymask: MDAY366MASK,
  9607. nmdaymask: NMDAY366MASK,
  9608. wdaymask: WDAYMASK.slice(wday),
  9609. mrange: M366RANGE
  9610. };
  9611. }
  9612. // CONCATENATED MODULE: ./src/iterinfo/monthinfo.ts
  9613. function rebuildMonth(year, month, yearlen, mrange, wdaymask, options) {
  9614. var result = {
  9615. lastyear: year,
  9616. lastmonth: month,
  9617. nwdaymask: []
  9618. };
  9619. var ranges = [];
  9620. if (options.freq === src_rrule.YEARLY) {
  9621. if (empty(options.bymonth)) {
  9622. ranges = [[0, yearlen]];
  9623. }
  9624. else {
  9625. for (var j = 0; j < options.bymonth.length; j++) {
  9626. month = options.bymonth[j];
  9627. ranges.push(mrange.slice(month - 1, month + 1));
  9628. }
  9629. }
  9630. }
  9631. else if (options.freq === src_rrule.MONTHLY) {
  9632. ranges = [mrange.slice(month - 1, month + 1)];
  9633. }
  9634. if (empty(ranges)) {
  9635. return result;
  9636. }
  9637. // Weekly frequency won't get here, so we may not
  9638. // care about cross-year weekly periods.
  9639. result.nwdaymask = repeat(0, yearlen);
  9640. for (var j = 0; j < ranges.length; j++) {
  9641. var rang = ranges[j];
  9642. var first = rang[0];
  9643. var last = rang[1] - 1;
  9644. for (var k = 0; k < options.bynweekday.length; k++) {
  9645. var i = void 0;
  9646. var _a = options.bynweekday[k], wday = _a[0], n = _a[1];
  9647. if (n < 0) {
  9648. i = last + (n + 1) * 7;
  9649. i -= pymod(wdaymask[i] - wday, 7);
  9650. }
  9651. else {
  9652. i = first + (n - 1) * 7;
  9653. i += pymod(7 - wdaymask[i] + wday, 7);
  9654. }
  9655. if (first <= i && i <= last)
  9656. result.nwdaymask[i] = 1;
  9657. }
  9658. }
  9659. return result;
  9660. }
  9661. // CONCATENATED MODULE: ./src/iterinfo/easter.ts
  9662. function easter(y, offset) {
  9663. if (offset === void 0) { offset = 0; }
  9664. var a = y % 19;
  9665. var b = Math.floor(y / 100);
  9666. var c = y % 100;
  9667. var d = Math.floor(b / 4);
  9668. var e = b % 4;
  9669. var f = Math.floor((b + 8) / 25);
  9670. var g = Math.floor((b - f + 1) / 3);
  9671. var h = Math.floor(19 * a + b - d - g + 15) % 30;
  9672. var i = Math.floor(c / 4);
  9673. var k = c % 4;
  9674. var l = Math.floor(32 + 2 * e + 2 * i - h - k) % 7;
  9675. var m = Math.floor((a + 11 * h + 22 * l) / 451);
  9676. var month = Math.floor((h + l - 7 * m + 114) / 31);
  9677. var day = ((h + l - 7 * m + 114) % 31) + 1;
  9678. var date = Date.UTC(y, month - 1, day + offset);
  9679. var yearStart = Date.UTC(y, 0, 1);
  9680. return [Math.ceil((date - yearStart) / (1000 * 60 * 60 * 24))];
  9681. }
  9682. // CONCATENATED MODULE: ./src/iterinfo/index.ts
  9683. // =============================================================================
  9684. // Iterinfo
  9685. // =============================================================================
  9686. var iterinfo_Iterinfo = /** @class */ (function () {
  9687. function Iterinfo(options) {
  9688. this.options = options;
  9689. }
  9690. Iterinfo.prototype.rebuild = function (year, month) {
  9691. var options = this.options;
  9692. if (year !== this.lastyear) {
  9693. this.yearinfo = rebuildYear(year, options);
  9694. }
  9695. if (notEmpty(options.bynweekday) &&
  9696. (month !== this.lastmonth || year !== this.lastyear)) {
  9697. var _a = this.yearinfo, yearlen = _a.yearlen, mrange = _a.mrange, wdaymask = _a.wdaymask;
  9698. this.monthinfo = rebuildMonth(year, month, yearlen, mrange, wdaymask, options);
  9699. }
  9700. if (isPresent(options.byeaster)) {
  9701. this.eastermask = easter(year, options.byeaster);
  9702. }
  9703. };
  9704. Object.defineProperty(Iterinfo.prototype, "lastyear", {
  9705. get: function () {
  9706. return this.monthinfo ? this.monthinfo.lastyear : null;
  9707. },
  9708. enumerable: true,
  9709. configurable: true
  9710. });
  9711. Object.defineProperty(Iterinfo.prototype, "lastmonth", {
  9712. get: function () {
  9713. return this.monthinfo ? this.monthinfo.lastmonth : null;
  9714. },
  9715. enumerable: true,
  9716. configurable: true
  9717. });
  9718. Object.defineProperty(Iterinfo.prototype, "yearlen", {
  9719. get: function () {
  9720. return this.yearinfo.yearlen;
  9721. },
  9722. enumerable: true,
  9723. configurable: true
  9724. });
  9725. Object.defineProperty(Iterinfo.prototype, "yearordinal", {
  9726. get: function () {
  9727. return this.yearinfo.yearordinal;
  9728. },
  9729. enumerable: true,
  9730. configurable: true
  9731. });
  9732. Object.defineProperty(Iterinfo.prototype, "mrange", {
  9733. get: function () {
  9734. return this.yearinfo.mrange;
  9735. },
  9736. enumerable: true,
  9737. configurable: true
  9738. });
  9739. Object.defineProperty(Iterinfo.prototype, "wdaymask", {
  9740. get: function () {
  9741. return this.yearinfo.wdaymask;
  9742. },
  9743. enumerable: true,
  9744. configurable: true
  9745. });
  9746. Object.defineProperty(Iterinfo.prototype, "mmask", {
  9747. get: function () {
  9748. return this.yearinfo.mmask;
  9749. },
  9750. enumerable: true,
  9751. configurable: true
  9752. });
  9753. Object.defineProperty(Iterinfo.prototype, "wnomask", {
  9754. get: function () {
  9755. return this.yearinfo.wnomask;
  9756. },
  9757. enumerable: true,
  9758. configurable: true
  9759. });
  9760. Object.defineProperty(Iterinfo.prototype, "nwdaymask", {
  9761. get: function () {
  9762. return this.monthinfo ? this.monthinfo.nwdaymask : [];
  9763. },
  9764. enumerable: true,
  9765. configurable: true
  9766. });
  9767. Object.defineProperty(Iterinfo.prototype, "nextyearlen", {
  9768. get: function () {
  9769. return this.yearinfo.nextyearlen;
  9770. },
  9771. enumerable: true,
  9772. configurable: true
  9773. });
  9774. Object.defineProperty(Iterinfo.prototype, "mdaymask", {
  9775. get: function () {
  9776. return this.yearinfo.mdaymask;
  9777. },
  9778. enumerable: true,
  9779. configurable: true
  9780. });
  9781. Object.defineProperty(Iterinfo.prototype, "nmdaymask", {
  9782. get: function () {
  9783. return this.yearinfo.nmdaymask;
  9784. },
  9785. enumerable: true,
  9786. configurable: true
  9787. });
  9788. Iterinfo.prototype.ydayset = function () {
  9789. return [range(this.yearlen), 0, this.yearlen];
  9790. };
  9791. Iterinfo.prototype.mdayset = function (_, month, __) {
  9792. var start = this.mrange[month - 1];
  9793. var end = this.mrange[month];
  9794. var set = repeat(null, this.yearlen);
  9795. for (var i = start; i < end; i++)
  9796. set[i] = i;
  9797. return [set, start, end];
  9798. };
  9799. Iterinfo.prototype.wdayset = function (year, month, day) {
  9800. // We need to handle cross-year weeks here.
  9801. var set = repeat(null, this.yearlen + 7);
  9802. var i = src_dateutil.toOrdinal(new Date(Date.UTC(year, month - 1, day))) -
  9803. this.yearordinal;
  9804. var start = i;
  9805. for (var j = 0; j < 7; j++) {
  9806. set[i] = i;
  9807. ++i;
  9808. if (this.wdaymask[i] === this.options.wkst)
  9809. break;
  9810. }
  9811. return [set, start, i];
  9812. };
  9813. Iterinfo.prototype.ddayset = function (year, month, day) {
  9814. var set = repeat(null, this.yearlen);
  9815. var i = src_dateutil.toOrdinal(new Date(Date.UTC(year, month - 1, day))) -
  9816. this.yearordinal;
  9817. set[i] = i;
  9818. return [set, i, i + 1];
  9819. };
  9820. Iterinfo.prototype.htimeset = function (hour, _, second, millisecond) {
  9821. var _this = this;
  9822. var set = [];
  9823. this.options.byminute.forEach(function (minute) {
  9824. set = set.concat(_this.mtimeset(hour, minute, second, millisecond));
  9825. });
  9826. src_dateutil.sort(set);
  9827. return set;
  9828. };
  9829. Iterinfo.prototype.mtimeset = function (hour, minute, _, millisecond) {
  9830. var set = this.options.bysecond.map(function (second) {
  9831. return new Time(hour, minute, second, millisecond);
  9832. });
  9833. src_dateutil.sort(set);
  9834. return set;
  9835. };
  9836. Iterinfo.prototype.stimeset = function (hour, minute, second, millisecond) {
  9837. return [new Time(hour, minute, second, millisecond)];
  9838. };
  9839. Iterinfo.prototype.getdayset = function (freq) {
  9840. switch (freq) {
  9841. case Frequency.YEARLY: return this.ydayset.bind(this);
  9842. case Frequency.MONTHLY: return this.mdayset.bind(this);
  9843. case Frequency.WEEKLY: return this.wdayset.bind(this);
  9844. case Frequency.DAILY: return this.ddayset.bind(this);
  9845. default: return this.ddayset.bind(this);
  9846. }
  9847. };
  9848. Iterinfo.prototype.gettimeset = function (freq) {
  9849. switch (freq) {
  9850. case Frequency.HOURLY: return this.htimeset.bind(this);
  9851. case Frequency.MINUTELY: return this.mtimeset.bind(this);
  9852. case Frequency.SECONDLY: return this.stimeset.bind(this);
  9853. }
  9854. };
  9855. return Iterinfo;
  9856. }());
  9857. /* harmony default export */ var iterinfo = (iterinfo_Iterinfo);
  9858. // CONCATENATED MODULE: ./src/iter/poslist.ts
  9859. function buildPoslist(bysetpos, timeset, start, end, ii, dayset) {
  9860. var poslist = [];
  9861. for (var j = 0; j < bysetpos.length; j++) {
  9862. var daypos = void 0;
  9863. var timepos = void 0;
  9864. var pos = bysetpos[j];
  9865. if (pos < 0) {
  9866. daypos = Math.floor(pos / timeset.length);
  9867. timepos = pymod(pos, timeset.length);
  9868. }
  9869. else {
  9870. daypos = Math.floor((pos - 1) / timeset.length);
  9871. timepos = pymod(pos - 1, timeset.length);
  9872. }
  9873. var tmp = [];
  9874. for (var k = start; k < end; k++) {
  9875. var val = dayset[k];
  9876. if (!isPresent(val))
  9877. continue;
  9878. tmp.push(val);
  9879. }
  9880. var i = void 0;
  9881. if (daypos < 0) {
  9882. i = tmp.slice(daypos)[0];
  9883. }
  9884. else {
  9885. i = tmp[daypos];
  9886. }
  9887. var time = timeset[timepos];
  9888. var date = src_dateutil.fromOrdinal(ii.yearordinal + i);
  9889. var res = src_dateutil.combine(date, time);
  9890. // XXX: can this ever be in the array?
  9891. // - compare the actual date instead?
  9892. if (!includes(poslist, res))
  9893. poslist.push(res);
  9894. }
  9895. src_dateutil.sort(poslist);
  9896. return poslist;
  9897. }
  9898. // CONCATENATED MODULE: ./src/iter/index.ts
  9899. function iter(iterResult, options) {
  9900. var dtstart = options.dtstart, freq = options.freq, interval = options.interval, until = options.until, bysetpos = options.bysetpos;
  9901. var count = options.count;
  9902. if (count === 0 || interval === 0) {
  9903. return emitResult(iterResult);
  9904. }
  9905. var counterDate = datetime_DateTime.fromDate(dtstart);
  9906. var ii = new iterinfo(options);
  9907. ii.rebuild(counterDate.year, counterDate.month);
  9908. var timeset = makeTimeset(ii, counterDate, options);
  9909. while (true) {
  9910. var _a = ii.getdayset(freq)(counterDate.year, counterDate.month, counterDate.day), dayset = _a[0], start = _a[1], end = _a[2];
  9911. var filtered = removeFilteredDays(dayset, start, end, ii, options);
  9912. if (notEmpty(bysetpos)) {
  9913. var poslist = buildPoslist(bysetpos, timeset, start, end, ii, dayset);
  9914. for (var j = 0; j < poslist.length; j++) {
  9915. var res = poslist[j];
  9916. if (until && res > until) {
  9917. return emitResult(iterResult);
  9918. }
  9919. if (res >= dtstart) {
  9920. var rezonedDate = rezoneIfNeeded(res, options);
  9921. if (!iterResult.accept(rezonedDate)) {
  9922. return emitResult(iterResult);
  9923. }
  9924. if (count) {
  9925. --count;
  9926. if (!count) {
  9927. return emitResult(iterResult);
  9928. }
  9929. }
  9930. }
  9931. }
  9932. }
  9933. else {
  9934. for (var j = start; j < end; j++) {
  9935. var currentDay = dayset[j];
  9936. if (!isPresent(currentDay)) {
  9937. continue;
  9938. }
  9939. var date = src_dateutil.fromOrdinal(ii.yearordinal + currentDay);
  9940. for (var k = 0; k < timeset.length; k++) {
  9941. var time = timeset[k];
  9942. var res = src_dateutil.combine(date, time);
  9943. if (until && res > until) {
  9944. return emitResult(iterResult);
  9945. }
  9946. if (res >= dtstart) {
  9947. var rezonedDate = rezoneIfNeeded(res, options);
  9948. if (!iterResult.accept(rezonedDate)) {
  9949. return emitResult(iterResult);
  9950. }
  9951. if (count) {
  9952. --count;
  9953. if (!count) {
  9954. return emitResult(iterResult);
  9955. }
  9956. }
  9957. }
  9958. }
  9959. }
  9960. }
  9961. if (options.interval === 0) {
  9962. return emitResult(iterResult);
  9963. }
  9964. // Handle frequency and interval
  9965. counterDate.add(options, filtered);
  9966. if (counterDate.year > src_dateutil.MAXYEAR) {
  9967. return emitResult(iterResult);
  9968. }
  9969. if (!freqIsDailyOrGreater(freq)) {
  9970. timeset = ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, 0);
  9971. }
  9972. ii.rebuild(counterDate.year, counterDate.month);
  9973. }
  9974. }
  9975. function isFiltered(ii, currentDay, options) {
  9976. var bymonth = options.bymonth, byweekno = options.byweekno, byweekday = options.byweekday, byeaster = options.byeaster, bymonthday = options.bymonthday, bynmonthday = options.bynmonthday, byyearday = options.byyearday;
  9977. return ((notEmpty(bymonth) && !includes(bymonth, ii.mmask[currentDay])) ||
  9978. (notEmpty(byweekno) && !ii.wnomask[currentDay]) ||
  9979. (notEmpty(byweekday) && !includes(byweekday, ii.wdaymask[currentDay])) ||
  9980. (notEmpty(ii.nwdaymask) && !ii.nwdaymask[currentDay]) ||
  9981. (byeaster !== null && !includes(ii.eastermask, currentDay)) ||
  9982. ((notEmpty(bymonthday) || notEmpty(bynmonthday)) &&
  9983. !includes(bymonthday, ii.mdaymask[currentDay]) &&
  9984. !includes(bynmonthday, ii.nmdaymask[currentDay])) ||
  9985. (notEmpty(byyearday) &&
  9986. ((currentDay < ii.yearlen &&
  9987. !includes(byyearday, currentDay + 1) &&
  9988. !includes(byyearday, -ii.yearlen + currentDay)) ||
  9989. (currentDay >= ii.yearlen &&
  9990. !includes(byyearday, currentDay + 1 - ii.yearlen) &&
  9991. !includes(byyearday, -ii.nextyearlen + currentDay - ii.yearlen)))));
  9992. }
  9993. function rezoneIfNeeded(date, options) {
  9994. return new datewithzone_DateWithZone(date, options.tzid).rezonedDate();
  9995. }
  9996. function emitResult(iterResult) {
  9997. return iterResult.getValue();
  9998. }
  9999. function removeFilteredDays(dayset, start, end, ii, options) {
  10000. var filtered = false;
  10001. for (var dayCounter = start; dayCounter < end; dayCounter++) {
  10002. var currentDay = dayset[dayCounter];
  10003. filtered = isFiltered(ii, currentDay, options);
  10004. if (filtered)
  10005. dayset[currentDay] = null;
  10006. }
  10007. return filtered;
  10008. }
  10009. function makeTimeset(ii, counterDate, options) {
  10010. var freq = options.freq, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
  10011. if (freqIsDailyOrGreater(freq)) {
  10012. return buildTimeset(options);
  10013. }
  10014. if ((freq >= src_rrule.HOURLY &&
  10015. notEmpty(byhour) &&
  10016. !includes(byhour, counterDate.hour)) ||
  10017. (freq >= src_rrule.MINUTELY &&
  10018. notEmpty(byminute) &&
  10019. !includes(byminute, counterDate.minute)) ||
  10020. (freq >= src_rrule.SECONDLY &&
  10021. notEmpty(bysecond) &&
  10022. !includes(bysecond, counterDate.second))) {
  10023. return [];
  10024. }
  10025. return ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, counterDate.millisecond);
  10026. }
  10027. // CONCATENATED MODULE: ./src/rrule.ts
  10028. // =============================================================================
  10029. // RRule
  10030. // =============================================================================
  10031. var Days = {
  10032. MO: new Weekday(0),
  10033. TU: new Weekday(1),
  10034. WE: new Weekday(2),
  10035. TH: new Weekday(3),
  10036. FR: new Weekday(4),
  10037. SA: new Weekday(5),
  10038. SU: new Weekday(6)
  10039. };
  10040. var DEFAULT_OPTIONS = {
  10041. freq: Frequency.YEARLY,
  10042. dtstart: null,
  10043. interval: 1,
  10044. wkst: Days.MO,
  10045. count: null,
  10046. until: null,
  10047. tzid: null,
  10048. bysetpos: null,
  10049. bymonth: null,
  10050. bymonthday: null,
  10051. bynmonthday: null,
  10052. byyearday: null,
  10053. byweekno: null,
  10054. byweekday: null,
  10055. bynweekday: null,
  10056. byhour: null,
  10057. byminute: null,
  10058. bysecond: null,
  10059. byeaster: null
  10060. };
  10061. var rrule_defaultKeys = Object.keys(DEFAULT_OPTIONS);
  10062. /**
  10063. *
  10064. * @param {Options?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
  10065. * The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
  10066. * @constructor
  10067. */
  10068. var rrule_RRule = /** @class */ (function () {
  10069. function RRule(options, noCache) {
  10070. if (options === void 0) { options = {}; }
  10071. if (noCache === void 0) { noCache = false; }
  10072. // RFC string
  10073. this._cache = noCache ? null : new cache_Cache();
  10074. // used by toString()
  10075. this.origOptions = initializeOptions(options);
  10076. var parsedOptions = parseOptions(options).parsedOptions;
  10077. this.options = parsedOptions;
  10078. }
  10079. RRule.parseText = function (text, language) {
  10080. return parseText(text, language);
  10081. };
  10082. RRule.fromText = function (text, language) {
  10083. return fromText(text, language);
  10084. };
  10085. RRule.fromString = function (str) {
  10086. return new RRule(RRule.parseString(str) || undefined);
  10087. };
  10088. RRule.prototype._iter = function (iterResult) {
  10089. return iter(iterResult, this.options);
  10090. };
  10091. RRule.prototype._cacheGet = function (what, args) {
  10092. if (!this._cache)
  10093. return false;
  10094. return this._cache._cacheGet(what, args);
  10095. };
  10096. RRule.prototype._cacheAdd = function (what, value, args) {
  10097. if (!this._cache)
  10098. return;
  10099. return this._cache._cacheAdd(what, value, args);
  10100. };
  10101. /**
  10102. * @param {Function} iterator - optional function that will be called
  10103. * on each date that is added. It can return false
  10104. * to stop the iteration.
  10105. * @return Array containing all recurrences.
  10106. */
  10107. RRule.prototype.all = function (iterator) {
  10108. if (iterator) {
  10109. return this._iter(new callbackiterresult('all', {}, iterator));
  10110. }
  10111. var result = this._cacheGet('all');
  10112. if (result === false) {
  10113. result = this._iter(new iterresult('all', {}));
  10114. this._cacheAdd('all', result);
  10115. }
  10116. return result;
  10117. };
  10118. /**
  10119. * Returns all the occurrences of the rrule between after and before.
  10120. * The inc keyword defines what happens if after and/or before are
  10121. * themselves occurrences. With inc == True, they will be included in the
  10122. * list, if they are found in the recurrence set.
  10123. * @return Array
  10124. */
  10125. RRule.prototype.between = function (after, before, inc, iterator) {
  10126. if (inc === void 0) { inc = false; }
  10127. if (!src_dateutil.isValidDate(after) || !src_dateutil.isValidDate(before))
  10128. throw new Error('Invalid date passed in to RRule.between');
  10129. var args = {
  10130. before: before,
  10131. after: after,
  10132. inc: inc
  10133. };
  10134. if (iterator) {
  10135. return this._iter(new callbackiterresult('between', args, iterator));
  10136. }
  10137. var result = this._cacheGet('between', args);
  10138. if (result === false) {
  10139. result = this._iter(new iterresult('between', args));
  10140. this._cacheAdd('between', result, args);
  10141. }
  10142. return result;
  10143. };
  10144. /**
  10145. * Returns the last recurrence before the given datetime instance.
  10146. * The inc keyword defines what happens if dt is an occurrence.
  10147. * With inc == True, if dt itself is an occurrence, it will be returned.
  10148. * @return Date or null
  10149. */
  10150. RRule.prototype.before = function (dt, inc) {
  10151. if (inc === void 0) { inc = false; }
  10152. if (!src_dateutil.isValidDate(dt))
  10153. throw new Error('Invalid date passed in to RRule.before');
  10154. var args = { dt: dt, inc: inc };
  10155. var result = this._cacheGet('before', args);
  10156. if (result === false) {
  10157. result = this._iter(new iterresult('before', args));
  10158. this._cacheAdd('before', result, args);
  10159. }
  10160. return result;
  10161. };
  10162. /**
  10163. * Returns the first recurrence after the given datetime instance.
  10164. * The inc keyword defines what happens if dt is an occurrence.
  10165. * With inc == True, if dt itself is an occurrence, it will be returned.
  10166. * @return Date or null
  10167. */
  10168. RRule.prototype.after = function (dt, inc) {
  10169. if (inc === void 0) { inc = false; }
  10170. if (!src_dateutil.isValidDate(dt))
  10171. throw new Error('Invalid date passed in to RRule.after');
  10172. var args = { dt: dt, inc: inc };
  10173. var result = this._cacheGet('after', args);
  10174. if (result === false) {
  10175. result = this._iter(new iterresult('after', args));
  10176. this._cacheAdd('after', result, args);
  10177. }
  10178. return result;
  10179. };
  10180. /**
  10181. * Returns the number of recurrences in this set. It will have go trough
  10182. * the whole recurrence, if this hasn't been done before.
  10183. */
  10184. RRule.prototype.count = function () {
  10185. return this.all().length;
  10186. };
  10187. /**
  10188. * Converts the rrule into its string representation
  10189. * @see <http://www.ietf.org/rfc/rfc2445.txt>
  10190. * @return String
  10191. */
  10192. RRule.prototype.toString = function () {
  10193. return optionsToString(this.origOptions);
  10194. };
  10195. /**
  10196. * Will convert all rules described in nlp:ToText
  10197. * to text.
  10198. */
  10199. RRule.prototype.toText = function (gettext, language, dateFormatter) {
  10200. return toText(this, gettext, language, dateFormatter);
  10201. };
  10202. RRule.prototype.isFullyConvertibleToText = function () {
  10203. return isFullyConvertible(this);
  10204. };
  10205. /**
  10206. * @return a RRule instance with the same freq and options
  10207. * as this one (cache is not cloned)
  10208. */
  10209. RRule.prototype.clone = function () {
  10210. return new RRule(this.origOptions);
  10211. };
  10212. // RRule class 'constants'
  10213. RRule.FREQUENCIES = [
  10214. 'YEARLY',
  10215. 'MONTHLY',
  10216. 'WEEKLY',
  10217. 'DAILY',
  10218. 'HOURLY',
  10219. 'MINUTELY',
  10220. 'SECONDLY'
  10221. ];
  10222. RRule.YEARLY = Frequency.YEARLY;
  10223. RRule.MONTHLY = Frequency.MONTHLY;
  10224. RRule.WEEKLY = Frequency.WEEKLY;
  10225. RRule.DAILY = Frequency.DAILY;
  10226. RRule.HOURLY = Frequency.HOURLY;
  10227. RRule.MINUTELY = Frequency.MINUTELY;
  10228. RRule.SECONDLY = Frequency.SECONDLY;
  10229. RRule.MO = Days.MO;
  10230. RRule.TU = Days.TU;
  10231. RRule.WE = Days.WE;
  10232. RRule.TH = Days.TH;
  10233. RRule.FR = Days.FR;
  10234. RRule.SA = Days.SA;
  10235. RRule.SU = Days.SU;
  10236. RRule.parseString = parseString;
  10237. RRule.optionsToString = optionsToString;
  10238. return RRule;
  10239. }());
  10240. /* harmony default export */ var src_rrule = (rrule_RRule);
  10241. // CONCATENATED MODULE: ./src/iterset.ts
  10242. function iterSet(iterResult, _rrule, _exrule, _rdate, _exdate, tzid) {
  10243. var _exdateHash = {};
  10244. var _accept = iterResult.accept;
  10245. function evalExdate(after, before) {
  10246. _exrule.forEach(function (rrule) {
  10247. rrule.between(after, before, true).forEach(function (date) {
  10248. _exdateHash[Number(date)] = true;
  10249. });
  10250. });
  10251. }
  10252. _exdate.forEach(function (date) {
  10253. var zonedDate = new datewithzone_DateWithZone(date, tzid).rezonedDate();
  10254. _exdateHash[Number(zonedDate)] = true;
  10255. });
  10256. iterResult.accept = function (date) {
  10257. var dt = Number(date);
  10258. if (isNaN(dt))
  10259. return _accept.call(this, date);
  10260. if (!_exdateHash[dt]) {
  10261. evalExdate(new Date(dt - 1), new Date(dt + 1));
  10262. if (!_exdateHash[dt]) {
  10263. _exdateHash[dt] = true;
  10264. return _accept.call(this, date);
  10265. }
  10266. }
  10267. return true;
  10268. };
  10269. if (iterResult.method === 'between') {
  10270. evalExdate(iterResult.args.after, iterResult.args.before);
  10271. iterResult.accept = function (date) {
  10272. var dt = Number(date);
  10273. if (!_exdateHash[dt]) {
  10274. _exdateHash[dt] = true;
  10275. return _accept.call(this, date);
  10276. }
  10277. return true;
  10278. };
  10279. }
  10280. for (var i = 0; i < _rdate.length; i++) {
  10281. var zonedDate = new datewithzone_DateWithZone(_rdate[i], tzid).rezonedDate();
  10282. if (!iterResult.accept(new Date(zonedDate.getTime())))
  10283. break;
  10284. }
  10285. _rrule.forEach(function (rrule) {
  10286. iter(iterResult, rrule.options);
  10287. });
  10288. var res = iterResult._result;
  10289. src_dateutil.sort(res);
  10290. switch (iterResult.method) {
  10291. case 'all':
  10292. case 'between':
  10293. return res;
  10294. case 'before':
  10295. return ((res.length && res[res.length - 1]) || null);
  10296. case 'after':
  10297. default:
  10298. return ((res.length && res[0]) || null);
  10299. }
  10300. }
  10301. // CONCATENATED MODULE: ./src/rrulestr.ts
  10302. /**
  10303. * RRuleStr
  10304. * To parse a set of rrule strings
  10305. */
  10306. var rrulestr_DEFAULT_OPTIONS = {
  10307. dtstart: null,
  10308. cache: false,
  10309. unfold: false,
  10310. forceset: false,
  10311. compatible: false,
  10312. tzid: null
  10313. };
  10314. function parseInput(s, options) {
  10315. var rrulevals = [];
  10316. var rdatevals = [];
  10317. var exrulevals = [];
  10318. var exdatevals = [];
  10319. var _a = parseDtstart(s), dtstart = _a.dtstart, tzid = _a.tzid;
  10320. var lines = splitIntoLines(s, options.unfold);
  10321. lines.forEach(function (line) {
  10322. if (!line)
  10323. return;
  10324. var _a = breakDownLine(line), name = _a.name, parms = _a.parms, value = _a.value;
  10325. switch (name.toUpperCase()) {
  10326. case 'RRULE':
  10327. if (parms.length) {
  10328. throw new Error("unsupported RRULE parm: " + parms.join(','));
  10329. }
  10330. rrulevals.push(parseString(line));
  10331. break;
  10332. case 'RDATE':
  10333. var _b = /RDATE(?:;TZID=([^:=]+))?/i.exec(line), _ = _b[0], rdateTzid = _b[1];
  10334. if (rdateTzid && !tzid) {
  10335. tzid = rdateTzid;
  10336. }
  10337. rdatevals = rdatevals.concat(parseRDate(value, parms));
  10338. break;
  10339. case 'EXRULE':
  10340. if (parms.length) {
  10341. throw new Error("unsupported EXRULE parm: " + parms.join(','));
  10342. }
  10343. exrulevals.push(parseString(value));
  10344. break;
  10345. case 'EXDATE':
  10346. exdatevals = exdatevals.concat(parseRDate(value, parms));
  10347. break;
  10348. case 'DTSTART':
  10349. break;
  10350. default:
  10351. throw new Error('unsupported property: ' + name);
  10352. }
  10353. });
  10354. return {
  10355. dtstart: dtstart,
  10356. tzid: tzid,
  10357. rrulevals: rrulevals,
  10358. rdatevals: rdatevals,
  10359. exrulevals: exrulevals,
  10360. exdatevals: exdatevals
  10361. };
  10362. }
  10363. function buildRule(s, options) {
  10364. var _a = parseInput(s, options), rrulevals = _a.rrulevals, rdatevals = _a.rdatevals, exrulevals = _a.exrulevals, exdatevals = _a.exdatevals, dtstart = _a.dtstart, tzid = _a.tzid;
  10365. var noCache = options.cache === false;
  10366. if (options.compatible) {
  10367. options.forceset = true;
  10368. options.unfold = true;
  10369. }
  10370. if (options.forceset ||
  10371. rrulevals.length > 1 ||
  10372. rdatevals.length ||
  10373. exrulevals.length ||
  10374. exdatevals.length) {
  10375. var rset_1 = new rruleset(noCache);
  10376. rset_1.dtstart(dtstart);
  10377. rset_1.tzid(tzid || undefined);
  10378. rrulevals.forEach(function (val) {
  10379. rset_1.rrule(new src_rrule(groomRruleOptions(val, dtstart, tzid), noCache));
  10380. });
  10381. rdatevals.forEach(function (date) {
  10382. rset_1.rdate(date);
  10383. });
  10384. exrulevals.forEach(function (val) {
  10385. rset_1.exrule(new src_rrule(groomRruleOptions(val, dtstart, tzid), noCache));
  10386. });
  10387. exdatevals.forEach(function (date) {
  10388. rset_1.exdate(date);
  10389. });
  10390. if (options.compatible && options.dtstart)
  10391. rset_1.rdate(dtstart);
  10392. return rset_1;
  10393. }
  10394. var val = rrulevals[0] || {};
  10395. return new src_rrule(groomRruleOptions(val, val.dtstart || options.dtstart || dtstart, val.tzid || options.tzid || tzid), noCache);
  10396. }
  10397. function rrulestr(s, options) {
  10398. if (options === void 0) { options = {}; }
  10399. return buildRule(s, rrulestr_initializeOptions(options));
  10400. }
  10401. function groomRruleOptions(val, dtstart, tzid) {
  10402. return __assign(__assign({}, val), { dtstart: dtstart,
  10403. tzid: tzid });
  10404. }
  10405. function rrulestr_initializeOptions(options) {
  10406. var invalid = [];
  10407. var keys = Object.keys(options);
  10408. var defaultKeys = Object.keys(rrulestr_DEFAULT_OPTIONS);
  10409. keys.forEach(function (key) {
  10410. if (!includes(defaultKeys, key))
  10411. invalid.push(key);
  10412. });
  10413. if (invalid.length) {
  10414. throw new Error('Invalid options: ' + invalid.join(', '));
  10415. }
  10416. return __assign(__assign({}, rrulestr_DEFAULT_OPTIONS), options);
  10417. }
  10418. function extractName(line) {
  10419. if (line.indexOf(':') === -1) {
  10420. return {
  10421. name: 'RRULE',
  10422. value: line
  10423. };
  10424. }
  10425. var _a = split(line, ':', 1), name = _a[0], value = _a[1];
  10426. return {
  10427. name: name,
  10428. value: value
  10429. };
  10430. }
  10431. function breakDownLine(line) {
  10432. var _a = extractName(line), name = _a.name, value = _a.value;
  10433. var parms = name.split(';');
  10434. if (!parms)
  10435. throw new Error('empty property name');
  10436. return {
  10437. name: parms[0].toUpperCase(),
  10438. parms: parms.slice(1),
  10439. value: value
  10440. };
  10441. }
  10442. function splitIntoLines(s, unfold) {
  10443. if (unfold === void 0) { unfold = false; }
  10444. s = s && s.trim();
  10445. if (!s)
  10446. throw new Error('Invalid empty string');
  10447. // More info about 'unfold' option
  10448. // Go head to http://www.ietf.org/rfc/rfc2445.txt
  10449. if (!unfold) {
  10450. return s.split(/\s/);
  10451. }
  10452. var lines = s.split('\n');
  10453. var i = 0;
  10454. while (i < lines.length) {
  10455. // TODO
  10456. var line = (lines[i] = lines[i].replace(/\s+$/g, ''));
  10457. if (!line) {
  10458. lines.splice(i, 1);
  10459. }
  10460. else if (i > 0 && line[0] === ' ') {
  10461. lines[i - 1] += line.slice(1);
  10462. lines.splice(i, 1);
  10463. }
  10464. else {
  10465. i += 1;
  10466. }
  10467. }
  10468. return lines;
  10469. }
  10470. function validateDateParm(parms) {
  10471. parms.forEach(function (parm) {
  10472. if (!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(parm)) {
  10473. throw new Error('unsupported RDATE/EXDATE parm: ' + parm);
  10474. }
  10475. });
  10476. }
  10477. function parseRDate(rdateval, parms) {
  10478. validateDateParm(parms);
  10479. return rdateval
  10480. .split(',')
  10481. .map(function (datestr) { return src_dateutil.untilStringToDate(datestr); });
  10482. }
  10483. // CONCATENATED MODULE: ./src/rruleset.ts
  10484. function createGetterSetter(fieldName) {
  10485. var _this = this;
  10486. return function (field) {
  10487. if (field !== undefined) {
  10488. _this["_" + fieldName] = field;
  10489. }
  10490. if (_this["_" + fieldName] !== undefined) {
  10491. return _this["_" + fieldName];
  10492. }
  10493. for (var i = 0; i < _this._rrule.length; i++) {
  10494. var field_1 = _this._rrule[i].origOptions[fieldName];
  10495. if (field_1) {
  10496. return field_1;
  10497. }
  10498. }
  10499. };
  10500. }
  10501. var rruleset_RRuleSet = /** @class */ (function (_super) {
  10502. __extends(RRuleSet, _super);
  10503. /**
  10504. *
  10505. * @param {Boolean?} noCache
  10506. * The same stratagy as RRule on cache, default to false
  10507. * @constructor
  10508. */
  10509. function RRuleSet(noCache) {
  10510. if (noCache === void 0) { noCache = false; }
  10511. var _this = _super.call(this, {}, noCache) || this;
  10512. _this.dtstart = createGetterSetter.apply(_this, ['dtstart']);
  10513. _this.tzid = createGetterSetter.apply(_this, ['tzid']);
  10514. _this._rrule = [];
  10515. _this._rdate = [];
  10516. _this._exrule = [];
  10517. _this._exdate = [];
  10518. return _this;
  10519. }
  10520. RRuleSet.prototype._iter = function (iterResult) {
  10521. return iterSet(iterResult, this._rrule, this._exrule, this._rdate, this._exdate, this.tzid());
  10522. };
  10523. /**
  10524. * Adds an RRule to the set
  10525. *
  10526. * @param {RRule}
  10527. */
  10528. RRuleSet.prototype.rrule = function (rrule) {
  10529. _addRule(rrule, this._rrule);
  10530. };
  10531. /**
  10532. * Adds an EXRULE to the set
  10533. *
  10534. * @param {RRule}
  10535. */
  10536. RRuleSet.prototype.exrule = function (rrule) {
  10537. _addRule(rrule, this._exrule);
  10538. };
  10539. /**
  10540. * Adds an RDate to the set
  10541. *
  10542. * @param {Date}
  10543. */
  10544. RRuleSet.prototype.rdate = function (date) {
  10545. _addDate(date, this._rdate);
  10546. };
  10547. /**
  10548. * Adds an EXDATE to the set
  10549. *
  10550. * @param {Date}
  10551. */
  10552. RRuleSet.prototype.exdate = function (date) {
  10553. _addDate(date, this._exdate);
  10554. };
  10555. /**
  10556. * Get list of included rrules in this recurrence set.
  10557. *
  10558. * @return List of rrules
  10559. */
  10560. RRuleSet.prototype.rrules = function () {
  10561. return this._rrule.map(function (e) { return rrulestr(e.toString()); });
  10562. };
  10563. /**
  10564. * Get list of excluded rrules in this recurrence set.
  10565. *
  10566. * @return List of exrules
  10567. */
  10568. RRuleSet.prototype.exrules = function () {
  10569. return this._exrule.map(function (e) { return rrulestr(e.toString()); });
  10570. };
  10571. /**
  10572. * Get list of included datetimes in this recurrence set.
  10573. *
  10574. * @return List of rdates
  10575. */
  10576. RRuleSet.prototype.rdates = function () {
  10577. return this._rdate.map(function (e) { return new Date(e.getTime()); });
  10578. };
  10579. /**
  10580. * Get list of included datetimes in this recurrence set.
  10581. *
  10582. * @return List of exdates
  10583. */
  10584. RRuleSet.prototype.exdates = function () {
  10585. return this._exdate.map(function (e) { return new Date(e.getTime()); });
  10586. };
  10587. RRuleSet.prototype.valueOf = function () {
  10588. var result = [];
  10589. if (!this._rrule.length && this._dtstart) {
  10590. result = result.concat(optionsToString({ dtstart: this._dtstart }));
  10591. }
  10592. this._rrule.forEach(function (rrule) {
  10593. result = result.concat(rrule.toString().split('\n'));
  10594. });
  10595. this._exrule.forEach(function (exrule) {
  10596. result = result.concat(exrule.toString().split('\n')
  10597. .map(function (line) { return line.replace(/^RRULE:/, 'EXRULE:'); })
  10598. .filter(function (line) { return !/^DTSTART/.test(line); }));
  10599. });
  10600. if (this._rdate.length) {
  10601. result.push(rdatesToString('RDATE', this._rdate, this.tzid()));
  10602. }
  10603. if (this._exdate.length) {
  10604. result.push(rdatesToString('EXDATE', this._exdate, this.tzid()));
  10605. }
  10606. return result;
  10607. };
  10608. /**
  10609. * to generate recurrence field such as:
  10610. * DTSTART:19970902T010000Z
  10611. * RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU
  10612. * RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH
  10613. */
  10614. RRuleSet.prototype.toString = function () {
  10615. return this.valueOf().join('\n');
  10616. };
  10617. /**
  10618. * Create a new RRuleSet Object completely base on current instance
  10619. */
  10620. RRuleSet.prototype.clone = function () {
  10621. var rrs = new RRuleSet(!!this._cache);
  10622. this._rrule.forEach(function (rule) { return rrs.rrule(rule.clone()); });
  10623. this._exrule.forEach(function (rule) { return rrs.exrule(rule.clone()); });
  10624. this._rdate.forEach(function (date) { return rrs.rdate(new Date(date.getTime())); });
  10625. this._exdate.forEach(function (date) { return rrs.exdate(new Date(date.getTime())); });
  10626. return rrs;
  10627. };
  10628. return RRuleSet;
  10629. }(src_rrule));
  10630. /* harmony default export */ var rruleset = (rruleset_RRuleSet);
  10631. function _addRule(rrule, collection) {
  10632. if (!(rrule instanceof src_rrule)) {
  10633. throw new TypeError(String(rrule) + ' is not RRule instance');
  10634. }
  10635. if (!includes(collection.map(String), String(rrule))) {
  10636. collection.push(rrule);
  10637. }
  10638. }
  10639. function _addDate(date, collection) {
  10640. if (!(date instanceof Date)) {
  10641. throw new TypeError(String(date) + ' is not Date instance');
  10642. }
  10643. if (!includes(collection.map(Number), Number(date))) {
  10644. collection.push(date);
  10645. src_dateutil.sort(collection);
  10646. }
  10647. }
  10648. function rdatesToString(param, rdates, tzid) {
  10649. var isUTC = !tzid || tzid.toUpperCase() === 'UTC';
  10650. var header = isUTC ? param + ":" : param + ";TZID=" + tzid + ":";
  10651. var dateString = rdates
  10652. .map(function (rdate) { return src_dateutil.timeToUntilString(rdate.valueOf(), isUTC); })
  10653. .join(',');
  10654. return "" + header + dateString;
  10655. }
  10656. // CONCATENATED MODULE: ./src/index.ts
  10657. /* concated harmony reexport rrulestr */__webpack_require__.d(__webpack_exports__, "rrulestr", function() { return rrulestr; });
  10658. /* concated harmony reexport Frequency */__webpack_require__.d(__webpack_exports__, "Frequency", function() { return Frequency; });
  10659. /* concated harmony reexport Weekday */__webpack_require__.d(__webpack_exports__, "Weekday", function() { return Weekday; });
  10660. /* concated harmony reexport RRule */__webpack_require__.d(__webpack_exports__, "RRule", function() { return src_rrule; });
  10661. /* concated harmony reexport RRuleSet */__webpack_require__.d(__webpack_exports__, "RRuleSet", function() { return rruleset; });
  10662. /*!
  10663. * rrule.js - Library for working with recurrence rules for calendar dates.
  10664. * https://github.com/jakubroztocil/rrule
  10665. *
  10666. * Copyright 2010, Jakub Roztocil and Lars Schoning
  10667. * Licenced under the BSD licence.
  10668. * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
  10669. *
  10670. * Based on:
  10671. * python-dateutil - Extensions to the standard Python datetime module.
  10672. * Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
  10673. * Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
  10674. * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
  10675. *
  10676. */
  10677. /* harmony default export */ var src = __webpack_exports__["default"] = (src_rrule);
  10678. /***/ })
  10679. /******/ ]);
  10680. });
  10681. //# sourceMappingURL=rrule-tz.js.map