Node-Red configuration
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685
  1. //! moment.js
  2. //! version : 2.29.4
  3. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  4. //! license : MIT
  5. //! momentjs.com
  6. ;(function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. global.moment = factory()
  10. }(this, (function () { 'use strict';
  11. var hookCallback;
  12. function hooks() {
  13. return hookCallback.apply(null, arguments);
  14. }
  15. // This is done to register the method called with moment()
  16. // without creating circular dependencies.
  17. function setHookCallback(callback) {
  18. hookCallback = callback;
  19. }
  20. function isArray(input) {
  21. return (
  22. input instanceof Array ||
  23. Object.prototype.toString.call(input) === '[object Array]'
  24. );
  25. }
  26. function isObject(input) {
  27. // IE8 will treat undefined and null as object if it wasn't for
  28. // input != null
  29. return (
  30. input != null &&
  31. Object.prototype.toString.call(input) === '[object Object]'
  32. );
  33. }
  34. function hasOwnProp(a, b) {
  35. return Object.prototype.hasOwnProperty.call(a, b);
  36. }
  37. function isObjectEmpty(obj) {
  38. if (Object.getOwnPropertyNames) {
  39. return Object.getOwnPropertyNames(obj).length === 0;
  40. } else {
  41. var k;
  42. for (k in obj) {
  43. if (hasOwnProp(obj, k)) {
  44. return false;
  45. }
  46. }
  47. return true;
  48. }
  49. }
  50. function isUndefined(input) {
  51. return input === void 0;
  52. }
  53. function isNumber(input) {
  54. return (
  55. typeof input === 'number' ||
  56. Object.prototype.toString.call(input) === '[object Number]'
  57. );
  58. }
  59. function isDate(input) {
  60. return (
  61. input instanceof Date ||
  62. Object.prototype.toString.call(input) === '[object Date]'
  63. );
  64. }
  65. function map(arr, fn) {
  66. var res = [],
  67. i,
  68. arrLen = arr.length;
  69. for (i = 0; i < arrLen; ++i) {
  70. res.push(fn(arr[i], i));
  71. }
  72. return res;
  73. }
  74. function extend(a, b) {
  75. for (var i in b) {
  76. if (hasOwnProp(b, i)) {
  77. a[i] = b[i];
  78. }
  79. }
  80. if (hasOwnProp(b, 'toString')) {
  81. a.toString = b.toString;
  82. }
  83. if (hasOwnProp(b, 'valueOf')) {
  84. a.valueOf = b.valueOf;
  85. }
  86. return a;
  87. }
  88. function createUTC(input, format, locale, strict) {
  89. return createLocalOrUTC(input, format, locale, strict, true).utc();
  90. }
  91. function defaultParsingFlags() {
  92. // We need to deep clone this object.
  93. return {
  94. empty: false,
  95. unusedTokens: [],
  96. unusedInput: [],
  97. overflow: -2,
  98. charsLeftOver: 0,
  99. nullInput: false,
  100. invalidEra: null,
  101. invalidMonth: null,
  102. invalidFormat: false,
  103. userInvalidated: false,
  104. iso: false,
  105. parsedDateParts: [],
  106. era: null,
  107. meridiem: null,
  108. rfc2822: false,
  109. weekdayMismatch: false,
  110. };
  111. }
  112. function getParsingFlags(m) {
  113. if (m._pf == null) {
  114. m._pf = defaultParsingFlags();
  115. }
  116. return m._pf;
  117. }
  118. var some;
  119. if (Array.prototype.some) {
  120. some = Array.prototype.some;
  121. } else {
  122. some = function (fun) {
  123. var t = Object(this),
  124. len = t.length >>> 0,
  125. i;
  126. for (i = 0; i < len; i++) {
  127. if (i in t && fun.call(this, t[i], i, t)) {
  128. return true;
  129. }
  130. }
  131. return false;
  132. };
  133. }
  134. function isValid(m) {
  135. if (m._isValid == null) {
  136. var flags = getParsingFlags(m),
  137. parsedParts = some.call(flags.parsedDateParts, function (i) {
  138. return i != null;
  139. }),
  140. isNowValid =
  141. !isNaN(m._d.getTime()) &&
  142. flags.overflow < 0 &&
  143. !flags.empty &&
  144. !flags.invalidEra &&
  145. !flags.invalidMonth &&
  146. !flags.invalidWeekday &&
  147. !flags.weekdayMismatch &&
  148. !flags.nullInput &&
  149. !flags.invalidFormat &&
  150. !flags.userInvalidated &&
  151. (!flags.meridiem || (flags.meridiem && parsedParts));
  152. if (m._strict) {
  153. isNowValid =
  154. isNowValid &&
  155. flags.charsLeftOver === 0 &&
  156. flags.unusedTokens.length === 0 &&
  157. flags.bigHour === undefined;
  158. }
  159. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  160. m._isValid = isNowValid;
  161. } else {
  162. return isNowValid;
  163. }
  164. }
  165. return m._isValid;
  166. }
  167. function createInvalid(flags) {
  168. var m = createUTC(NaN);
  169. if (flags != null) {
  170. extend(getParsingFlags(m), flags);
  171. } else {
  172. getParsingFlags(m).userInvalidated = true;
  173. }
  174. return m;
  175. }
  176. // Plugins that add properties should also add the key here (null value),
  177. // so we can properly clone ourselves.
  178. var momentProperties = (hooks.momentProperties = []),
  179. updateInProgress = false;
  180. function copyConfig(to, from) {
  181. var i,
  182. prop,
  183. val,
  184. momentPropertiesLen = momentProperties.length;
  185. if (!isUndefined(from._isAMomentObject)) {
  186. to._isAMomentObject = from._isAMomentObject;
  187. }
  188. if (!isUndefined(from._i)) {
  189. to._i = from._i;
  190. }
  191. if (!isUndefined(from._f)) {
  192. to._f = from._f;
  193. }
  194. if (!isUndefined(from._l)) {
  195. to._l = from._l;
  196. }
  197. if (!isUndefined(from._strict)) {
  198. to._strict = from._strict;
  199. }
  200. if (!isUndefined(from._tzm)) {
  201. to._tzm = from._tzm;
  202. }
  203. if (!isUndefined(from._isUTC)) {
  204. to._isUTC = from._isUTC;
  205. }
  206. if (!isUndefined(from._offset)) {
  207. to._offset = from._offset;
  208. }
  209. if (!isUndefined(from._pf)) {
  210. to._pf = getParsingFlags(from);
  211. }
  212. if (!isUndefined(from._locale)) {
  213. to._locale = from._locale;
  214. }
  215. if (momentPropertiesLen > 0) {
  216. for (i = 0; i < momentPropertiesLen; i++) {
  217. prop = momentProperties[i];
  218. val = from[prop];
  219. if (!isUndefined(val)) {
  220. to[prop] = val;
  221. }
  222. }
  223. }
  224. return to;
  225. }
  226. // Moment prototype object
  227. function Moment(config) {
  228. copyConfig(this, config);
  229. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  230. if (!this.isValid()) {
  231. this._d = new Date(NaN);
  232. }
  233. // Prevent infinite loop in case updateOffset creates new moment
  234. // objects.
  235. if (updateInProgress === false) {
  236. updateInProgress = true;
  237. hooks.updateOffset(this);
  238. updateInProgress = false;
  239. }
  240. }
  241. function isMoment(obj) {
  242. return (
  243. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  244. );
  245. }
  246. function warn(msg) {
  247. if (
  248. hooks.suppressDeprecationWarnings === false &&
  249. typeof console !== 'undefined' &&
  250. console.warn
  251. ) {
  252. console.warn('Deprecation warning: ' + msg);
  253. }
  254. }
  255. function deprecate(msg, fn) {
  256. var firstTime = true;
  257. return extend(function () {
  258. if (hooks.deprecationHandler != null) {
  259. hooks.deprecationHandler(null, msg);
  260. }
  261. if (firstTime) {
  262. var args = [],
  263. arg,
  264. i,
  265. key,
  266. argLen = arguments.length;
  267. for (i = 0; i < argLen; i++) {
  268. arg = '';
  269. if (typeof arguments[i] === 'object') {
  270. arg += '\n[' + i + '] ';
  271. for (key in arguments[0]) {
  272. if (hasOwnProp(arguments[0], key)) {
  273. arg += key + ': ' + arguments[0][key] + ', ';
  274. }
  275. }
  276. arg = arg.slice(0, -2); // Remove trailing comma and space
  277. } else {
  278. arg = arguments[i];
  279. }
  280. args.push(arg);
  281. }
  282. warn(
  283. msg +
  284. '\nArguments: ' +
  285. Array.prototype.slice.call(args).join('') +
  286. '\n' +
  287. new Error().stack
  288. );
  289. firstTime = false;
  290. }
  291. return fn.apply(this, arguments);
  292. }, fn);
  293. }
  294. var deprecations = {};
  295. function deprecateSimple(name, msg) {
  296. if (hooks.deprecationHandler != null) {
  297. hooks.deprecationHandler(name, msg);
  298. }
  299. if (!deprecations[name]) {
  300. warn(msg);
  301. deprecations[name] = true;
  302. }
  303. }
  304. hooks.suppressDeprecationWarnings = false;
  305. hooks.deprecationHandler = null;
  306. function isFunction(input) {
  307. return (
  308. (typeof Function !== 'undefined' && input instanceof Function) ||
  309. Object.prototype.toString.call(input) === '[object Function]'
  310. );
  311. }
  312. function set(config) {
  313. var prop, i;
  314. for (i in config) {
  315. if (hasOwnProp(config, i)) {
  316. prop = config[i];
  317. if (isFunction(prop)) {
  318. this[i] = prop;
  319. } else {
  320. this['_' + i] = prop;
  321. }
  322. }
  323. }
  324. this._config = config;
  325. // Lenient ordinal parsing accepts just a number in addition to
  326. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  327. // TODO: Remove "ordinalParse" fallback in next major release.
  328. this._dayOfMonthOrdinalParseLenient = new RegExp(
  329. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  330. '|' +
  331. /\d{1,2}/.source
  332. );
  333. }
  334. function mergeConfigs(parentConfig, childConfig) {
  335. var res = extend({}, parentConfig),
  336. prop;
  337. for (prop in childConfig) {
  338. if (hasOwnProp(childConfig, prop)) {
  339. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  340. res[prop] = {};
  341. extend(res[prop], parentConfig[prop]);
  342. extend(res[prop], childConfig[prop]);
  343. } else if (childConfig[prop] != null) {
  344. res[prop] = childConfig[prop];
  345. } else {
  346. delete res[prop];
  347. }
  348. }
  349. }
  350. for (prop in parentConfig) {
  351. if (
  352. hasOwnProp(parentConfig, prop) &&
  353. !hasOwnProp(childConfig, prop) &&
  354. isObject(parentConfig[prop])
  355. ) {
  356. // make sure changes to properties don't modify parent config
  357. res[prop] = extend({}, res[prop]);
  358. }
  359. }
  360. return res;
  361. }
  362. function Locale(config) {
  363. if (config != null) {
  364. this.set(config);
  365. }
  366. }
  367. var keys;
  368. if (Object.keys) {
  369. keys = Object.keys;
  370. } else {
  371. keys = function (obj) {
  372. var i,
  373. res = [];
  374. for (i in obj) {
  375. if (hasOwnProp(obj, i)) {
  376. res.push(i);
  377. }
  378. }
  379. return res;
  380. };
  381. }
  382. var defaultCalendar = {
  383. sameDay: '[Today at] LT',
  384. nextDay: '[Tomorrow at] LT',
  385. nextWeek: 'dddd [at] LT',
  386. lastDay: '[Yesterday at] LT',
  387. lastWeek: '[Last] dddd [at] LT',
  388. sameElse: 'L',
  389. };
  390. function calendar(key, mom, now) {
  391. var output = this._calendar[key] || this._calendar['sameElse'];
  392. return isFunction(output) ? output.call(mom, now) : output;
  393. }
  394. function zeroFill(number, targetLength, forceSign) {
  395. var absNumber = '' + Math.abs(number),
  396. zerosToFill = targetLength - absNumber.length,
  397. sign = number >= 0;
  398. return (
  399. (sign ? (forceSign ? '+' : '') : '-') +
  400. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  401. absNumber
  402. );
  403. }
  404. var formattingTokens =
  405. /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
  406. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  407. formatFunctions = {},
  408. formatTokenFunctions = {};
  409. // token: 'M'
  410. // padded: ['MM', 2]
  411. // ordinal: 'Mo'
  412. // callback: function () { this.month() + 1 }
  413. function addFormatToken(token, padded, ordinal, callback) {
  414. var func = callback;
  415. if (typeof callback === 'string') {
  416. func = function () {
  417. return this[callback]();
  418. };
  419. }
  420. if (token) {
  421. formatTokenFunctions[token] = func;
  422. }
  423. if (padded) {
  424. formatTokenFunctions[padded[0]] = function () {
  425. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  426. };
  427. }
  428. if (ordinal) {
  429. formatTokenFunctions[ordinal] = function () {
  430. return this.localeData().ordinal(
  431. func.apply(this, arguments),
  432. token
  433. );
  434. };
  435. }
  436. }
  437. function removeFormattingTokens(input) {
  438. if (input.match(/\[[\s\S]/)) {
  439. return input.replace(/^\[|\]$/g, '');
  440. }
  441. return input.replace(/\\/g, '');
  442. }
  443. function makeFormatFunction(format) {
  444. var array = format.match(formattingTokens),
  445. i,
  446. length;
  447. for (i = 0, length = array.length; i < length; i++) {
  448. if (formatTokenFunctions[array[i]]) {
  449. array[i] = formatTokenFunctions[array[i]];
  450. } else {
  451. array[i] = removeFormattingTokens(array[i]);
  452. }
  453. }
  454. return function (mom) {
  455. var output = '',
  456. i;
  457. for (i = 0; i < length; i++) {
  458. output += isFunction(array[i])
  459. ? array[i].call(mom, format)
  460. : array[i];
  461. }
  462. return output;
  463. };
  464. }
  465. // format date using native date object
  466. function formatMoment(m, format) {
  467. if (!m.isValid()) {
  468. return m.localeData().invalidDate();
  469. }
  470. format = expandFormat(format, m.localeData());
  471. formatFunctions[format] =
  472. formatFunctions[format] || makeFormatFunction(format);
  473. return formatFunctions[format](m);
  474. }
  475. function expandFormat(format, locale) {
  476. var i = 5;
  477. function replaceLongDateFormatTokens(input) {
  478. return locale.longDateFormat(input) || input;
  479. }
  480. localFormattingTokens.lastIndex = 0;
  481. while (i >= 0 && localFormattingTokens.test(format)) {
  482. format = format.replace(
  483. localFormattingTokens,
  484. replaceLongDateFormatTokens
  485. );
  486. localFormattingTokens.lastIndex = 0;
  487. i -= 1;
  488. }
  489. return format;
  490. }
  491. var defaultLongDateFormat = {
  492. LTS: 'h:mm:ss A',
  493. LT: 'h:mm A',
  494. L: 'MM/DD/YYYY',
  495. LL: 'MMMM D, YYYY',
  496. LLL: 'MMMM D, YYYY h:mm A',
  497. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  498. };
  499. function longDateFormat(key) {
  500. var format = this._longDateFormat[key],
  501. formatUpper = this._longDateFormat[key.toUpperCase()];
  502. if (format || !formatUpper) {
  503. return format;
  504. }
  505. this._longDateFormat[key] = formatUpper
  506. .match(formattingTokens)
  507. .map(function (tok) {
  508. if (
  509. tok === 'MMMM' ||
  510. tok === 'MM' ||
  511. tok === 'DD' ||
  512. tok === 'dddd'
  513. ) {
  514. return tok.slice(1);
  515. }
  516. return tok;
  517. })
  518. .join('');
  519. return this._longDateFormat[key];
  520. }
  521. var defaultInvalidDate = 'Invalid date';
  522. function invalidDate() {
  523. return this._invalidDate;
  524. }
  525. var defaultOrdinal = '%d',
  526. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  527. function ordinal(number) {
  528. return this._ordinal.replace('%d', number);
  529. }
  530. var defaultRelativeTime = {
  531. future: 'in %s',
  532. past: '%s ago',
  533. s: 'a few seconds',
  534. ss: '%d seconds',
  535. m: 'a minute',
  536. mm: '%d minutes',
  537. h: 'an hour',
  538. hh: '%d hours',
  539. d: 'a day',
  540. dd: '%d days',
  541. w: 'a week',
  542. ww: '%d weeks',
  543. M: 'a month',
  544. MM: '%d months',
  545. y: 'a year',
  546. yy: '%d years',
  547. };
  548. function relativeTime(number, withoutSuffix, string, isFuture) {
  549. var output = this._relativeTime[string];
  550. return isFunction(output)
  551. ? output(number, withoutSuffix, string, isFuture)
  552. : output.replace(/%d/i, number);
  553. }
  554. function pastFuture(diff, output) {
  555. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  556. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  557. }
  558. var aliases = {};
  559. function addUnitAlias(unit, shorthand) {
  560. var lowerCase = unit.toLowerCase();
  561. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  562. }
  563. function normalizeUnits(units) {
  564. return typeof units === 'string'
  565. ? aliases[units] || aliases[units.toLowerCase()]
  566. : undefined;
  567. }
  568. function normalizeObjectUnits(inputObject) {
  569. var normalizedInput = {},
  570. normalizedProp,
  571. prop;
  572. for (prop in inputObject) {
  573. if (hasOwnProp(inputObject, prop)) {
  574. normalizedProp = normalizeUnits(prop);
  575. if (normalizedProp) {
  576. normalizedInput[normalizedProp] = inputObject[prop];
  577. }
  578. }
  579. }
  580. return normalizedInput;
  581. }
  582. var priorities = {};
  583. function addUnitPriority(unit, priority) {
  584. priorities[unit] = priority;
  585. }
  586. function getPrioritizedUnits(unitsObj) {
  587. var units = [],
  588. u;
  589. for (u in unitsObj) {
  590. if (hasOwnProp(unitsObj, u)) {
  591. units.push({ unit: u, priority: priorities[u] });
  592. }
  593. }
  594. units.sort(function (a, b) {
  595. return a.priority - b.priority;
  596. });
  597. return units;
  598. }
  599. function isLeapYear(year) {
  600. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  601. }
  602. function absFloor(number) {
  603. if (number < 0) {
  604. // -0 -> 0
  605. return Math.ceil(number) || 0;
  606. } else {
  607. return Math.floor(number);
  608. }
  609. }
  610. function toInt(argumentForCoercion) {
  611. var coercedNumber = +argumentForCoercion,
  612. value = 0;
  613. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  614. value = absFloor(coercedNumber);
  615. }
  616. return value;
  617. }
  618. function makeGetSet(unit, keepTime) {
  619. return function (value) {
  620. if (value != null) {
  621. set$1(this, unit, value);
  622. hooks.updateOffset(this, keepTime);
  623. return this;
  624. } else {
  625. return get(this, unit);
  626. }
  627. };
  628. }
  629. function get(mom, unit) {
  630. return mom.isValid()
  631. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  632. : NaN;
  633. }
  634. function set$1(mom, unit, value) {
  635. if (mom.isValid() && !isNaN(value)) {
  636. if (
  637. unit === 'FullYear' &&
  638. isLeapYear(mom.year()) &&
  639. mom.month() === 1 &&
  640. mom.date() === 29
  641. ) {
  642. value = toInt(value);
  643. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  644. value,
  645. mom.month(),
  646. daysInMonth(value, mom.month())
  647. );
  648. } else {
  649. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  650. }
  651. }
  652. }
  653. // MOMENTS
  654. function stringGet(units) {
  655. units = normalizeUnits(units);
  656. if (isFunction(this[units])) {
  657. return this[units]();
  658. }
  659. return this;
  660. }
  661. function stringSet(units, value) {
  662. if (typeof units === 'object') {
  663. units = normalizeObjectUnits(units);
  664. var prioritized = getPrioritizedUnits(units),
  665. i,
  666. prioritizedLen = prioritized.length;
  667. for (i = 0; i < prioritizedLen; i++) {
  668. this[prioritized[i].unit](units[prioritized[i].unit]);
  669. }
  670. } else {
  671. units = normalizeUnits(units);
  672. if (isFunction(this[units])) {
  673. return this[units](value);
  674. }
  675. }
  676. return this;
  677. }
  678. var match1 = /\d/, // 0 - 9
  679. match2 = /\d\d/, // 00 - 99
  680. match3 = /\d{3}/, // 000 - 999
  681. match4 = /\d{4}/, // 0000 - 9999
  682. match6 = /[+-]?\d{6}/, // -999999 - 999999
  683. match1to2 = /\d\d?/, // 0 - 99
  684. match3to4 = /\d\d\d\d?/, // 999 - 9999
  685. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  686. match1to3 = /\d{1,3}/, // 0 - 999
  687. match1to4 = /\d{1,4}/, // 0 - 9999
  688. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  689. matchUnsigned = /\d+/, // 0 - inf
  690. matchSigned = /[+-]?\d+/, // -inf - inf
  691. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  692. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  693. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  694. // any word (or two) characters or numbers including two/three word month in arabic.
  695. // includes scottish gaelic two word and hyphenated months
  696. matchWord =
  697. /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
  698. regexes;
  699. regexes = {};
  700. function addRegexToken(token, regex, strictRegex) {
  701. regexes[token] = isFunction(regex)
  702. ? regex
  703. : function (isStrict, localeData) {
  704. return isStrict && strictRegex ? strictRegex : regex;
  705. };
  706. }
  707. function getParseRegexForToken(token, config) {
  708. if (!hasOwnProp(regexes, token)) {
  709. return new RegExp(unescapeFormat(token));
  710. }
  711. return regexes[token](config._strict, config._locale);
  712. }
  713. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  714. function unescapeFormat(s) {
  715. return regexEscape(
  716. s
  717. .replace('\\', '')
  718. .replace(
  719. /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
  720. function (matched, p1, p2, p3, p4) {
  721. return p1 || p2 || p3 || p4;
  722. }
  723. )
  724. );
  725. }
  726. function regexEscape(s) {
  727. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  728. }
  729. var tokens = {};
  730. function addParseToken(token, callback) {
  731. var i,
  732. func = callback,
  733. tokenLen;
  734. if (typeof token === 'string') {
  735. token = [token];
  736. }
  737. if (isNumber(callback)) {
  738. func = function (input, array) {
  739. array[callback] = toInt(input);
  740. };
  741. }
  742. tokenLen = token.length;
  743. for (i = 0; i < tokenLen; i++) {
  744. tokens[token[i]] = func;
  745. }
  746. }
  747. function addWeekParseToken(token, callback) {
  748. addParseToken(token, function (input, array, config, token) {
  749. config._w = config._w || {};
  750. callback(input, config._w, config, token);
  751. });
  752. }
  753. function addTimeToArrayFromToken(token, input, config) {
  754. if (input != null && hasOwnProp(tokens, token)) {
  755. tokens[token](input, config._a, config, token);
  756. }
  757. }
  758. var YEAR = 0,
  759. MONTH = 1,
  760. DATE = 2,
  761. HOUR = 3,
  762. MINUTE = 4,
  763. SECOND = 5,
  764. MILLISECOND = 6,
  765. WEEK = 7,
  766. WEEKDAY = 8;
  767. function mod(n, x) {
  768. return ((n % x) + x) % x;
  769. }
  770. var indexOf;
  771. if (Array.prototype.indexOf) {
  772. indexOf = Array.prototype.indexOf;
  773. } else {
  774. indexOf = function (o) {
  775. // I know
  776. var i;
  777. for (i = 0; i < this.length; ++i) {
  778. if (this[i] === o) {
  779. return i;
  780. }
  781. }
  782. return -1;
  783. };
  784. }
  785. function daysInMonth(year, month) {
  786. if (isNaN(year) || isNaN(month)) {
  787. return NaN;
  788. }
  789. var modMonth = mod(month, 12);
  790. year += (month - modMonth) / 12;
  791. return modMonth === 1
  792. ? isLeapYear(year)
  793. ? 29
  794. : 28
  795. : 31 - ((modMonth % 7) % 2);
  796. }
  797. // FORMATTING
  798. addFormatToken('M', ['MM', 2], 'Mo', function () {
  799. return this.month() + 1;
  800. });
  801. addFormatToken('MMM', 0, 0, function (format) {
  802. return this.localeData().monthsShort(this, format);
  803. });
  804. addFormatToken('MMMM', 0, 0, function (format) {
  805. return this.localeData().months(this, format);
  806. });
  807. // ALIASES
  808. addUnitAlias('month', 'M');
  809. // PRIORITY
  810. addUnitPriority('month', 8);
  811. // PARSING
  812. addRegexToken('M', match1to2);
  813. addRegexToken('MM', match1to2, match2);
  814. addRegexToken('MMM', function (isStrict, locale) {
  815. return locale.monthsShortRegex(isStrict);
  816. });
  817. addRegexToken('MMMM', function (isStrict, locale) {
  818. return locale.monthsRegex(isStrict);
  819. });
  820. addParseToken(['M', 'MM'], function (input, array) {
  821. array[MONTH] = toInt(input) - 1;
  822. });
  823. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  824. var month = config._locale.monthsParse(input, token, config._strict);
  825. // if we didn't find a month name, mark the date as invalid.
  826. if (month != null) {
  827. array[MONTH] = month;
  828. } else {
  829. getParsingFlags(config).invalidMonth = input;
  830. }
  831. });
  832. // LOCALES
  833. var defaultLocaleMonths =
  834. 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  835. '_'
  836. ),
  837. defaultLocaleMonthsShort =
  838. 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  839. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  840. defaultMonthsShortRegex = matchWord,
  841. defaultMonthsRegex = matchWord;
  842. function localeMonths(m, format) {
  843. if (!m) {
  844. return isArray(this._months)
  845. ? this._months
  846. : this._months['standalone'];
  847. }
  848. return isArray(this._months)
  849. ? this._months[m.month()]
  850. : this._months[
  851. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  852. ? 'format'
  853. : 'standalone'
  854. ][m.month()];
  855. }
  856. function localeMonthsShort(m, format) {
  857. if (!m) {
  858. return isArray(this._monthsShort)
  859. ? this._monthsShort
  860. : this._monthsShort['standalone'];
  861. }
  862. return isArray(this._monthsShort)
  863. ? this._monthsShort[m.month()]
  864. : this._monthsShort[
  865. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  866. ][m.month()];
  867. }
  868. function handleStrictParse(monthName, format, strict) {
  869. var i,
  870. ii,
  871. mom,
  872. llc = monthName.toLocaleLowerCase();
  873. if (!this._monthsParse) {
  874. // this is not used
  875. this._monthsParse = [];
  876. this._longMonthsParse = [];
  877. this._shortMonthsParse = [];
  878. for (i = 0; i < 12; ++i) {
  879. mom = createUTC([2000, i]);
  880. this._shortMonthsParse[i] = this.monthsShort(
  881. mom,
  882. ''
  883. ).toLocaleLowerCase();
  884. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  885. }
  886. }
  887. if (strict) {
  888. if (format === 'MMM') {
  889. ii = indexOf.call(this._shortMonthsParse, llc);
  890. return ii !== -1 ? ii : null;
  891. } else {
  892. ii = indexOf.call(this._longMonthsParse, llc);
  893. return ii !== -1 ? ii : null;
  894. }
  895. } else {
  896. if (format === 'MMM') {
  897. ii = indexOf.call(this._shortMonthsParse, llc);
  898. if (ii !== -1) {
  899. return ii;
  900. }
  901. ii = indexOf.call(this._longMonthsParse, llc);
  902. return ii !== -1 ? ii : null;
  903. } else {
  904. ii = indexOf.call(this._longMonthsParse, llc);
  905. if (ii !== -1) {
  906. return ii;
  907. }
  908. ii = indexOf.call(this._shortMonthsParse, llc);
  909. return ii !== -1 ? ii : null;
  910. }
  911. }
  912. }
  913. function localeMonthsParse(monthName, format, strict) {
  914. var i, mom, regex;
  915. if (this._monthsParseExact) {
  916. return handleStrictParse.call(this, monthName, format, strict);
  917. }
  918. if (!this._monthsParse) {
  919. this._monthsParse = [];
  920. this._longMonthsParse = [];
  921. this._shortMonthsParse = [];
  922. }
  923. // TODO: add sorting
  924. // Sorting makes sure if one month (or abbr) is a prefix of another
  925. // see sorting in computeMonthsParse
  926. for (i = 0; i < 12; i++) {
  927. // make the regex if we don't have it already
  928. mom = createUTC([2000, i]);
  929. if (strict && !this._longMonthsParse[i]) {
  930. this._longMonthsParse[i] = new RegExp(
  931. '^' + this.months(mom, '').replace('.', '') + '$',
  932. 'i'
  933. );
  934. this._shortMonthsParse[i] = new RegExp(
  935. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  936. 'i'
  937. );
  938. }
  939. if (!strict && !this._monthsParse[i]) {
  940. regex =
  941. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  942. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  943. }
  944. // test the regex
  945. if (
  946. strict &&
  947. format === 'MMMM' &&
  948. this._longMonthsParse[i].test(monthName)
  949. ) {
  950. return i;
  951. } else if (
  952. strict &&
  953. format === 'MMM' &&
  954. this._shortMonthsParse[i].test(monthName)
  955. ) {
  956. return i;
  957. } else if (!strict && this._monthsParse[i].test(monthName)) {
  958. return i;
  959. }
  960. }
  961. }
  962. // MOMENTS
  963. function setMonth(mom, value) {
  964. var dayOfMonth;
  965. if (!mom.isValid()) {
  966. // No op
  967. return mom;
  968. }
  969. if (typeof value === 'string') {
  970. if (/^\d+$/.test(value)) {
  971. value = toInt(value);
  972. } else {
  973. value = mom.localeData().monthsParse(value);
  974. // TODO: Another silent failure?
  975. if (!isNumber(value)) {
  976. return mom;
  977. }
  978. }
  979. }
  980. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  981. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  982. return mom;
  983. }
  984. function getSetMonth(value) {
  985. if (value != null) {
  986. setMonth(this, value);
  987. hooks.updateOffset(this, true);
  988. return this;
  989. } else {
  990. return get(this, 'Month');
  991. }
  992. }
  993. function getDaysInMonth() {
  994. return daysInMonth(this.year(), this.month());
  995. }
  996. function monthsShortRegex(isStrict) {
  997. if (this._monthsParseExact) {
  998. if (!hasOwnProp(this, '_monthsRegex')) {
  999. computeMonthsParse.call(this);
  1000. }
  1001. if (isStrict) {
  1002. return this._monthsShortStrictRegex;
  1003. } else {
  1004. return this._monthsShortRegex;
  1005. }
  1006. } else {
  1007. if (!hasOwnProp(this, '_monthsShortRegex')) {
  1008. this._monthsShortRegex = defaultMonthsShortRegex;
  1009. }
  1010. return this._monthsShortStrictRegex && isStrict
  1011. ? this._monthsShortStrictRegex
  1012. : this._monthsShortRegex;
  1013. }
  1014. }
  1015. function monthsRegex(isStrict) {
  1016. if (this._monthsParseExact) {
  1017. if (!hasOwnProp(this, '_monthsRegex')) {
  1018. computeMonthsParse.call(this);
  1019. }
  1020. if (isStrict) {
  1021. return this._monthsStrictRegex;
  1022. } else {
  1023. return this._monthsRegex;
  1024. }
  1025. } else {
  1026. if (!hasOwnProp(this, '_monthsRegex')) {
  1027. this._monthsRegex = defaultMonthsRegex;
  1028. }
  1029. return this._monthsStrictRegex && isStrict
  1030. ? this._monthsStrictRegex
  1031. : this._monthsRegex;
  1032. }
  1033. }
  1034. function computeMonthsParse() {
  1035. function cmpLenRev(a, b) {
  1036. return b.length - a.length;
  1037. }
  1038. var shortPieces = [],
  1039. longPieces = [],
  1040. mixedPieces = [],
  1041. i,
  1042. mom;
  1043. for (i = 0; i < 12; i++) {
  1044. // make the regex if we don't have it already
  1045. mom = createUTC([2000, i]);
  1046. shortPieces.push(this.monthsShort(mom, ''));
  1047. longPieces.push(this.months(mom, ''));
  1048. mixedPieces.push(this.months(mom, ''));
  1049. mixedPieces.push(this.monthsShort(mom, ''));
  1050. }
  1051. // Sorting makes sure if one month (or abbr) is a prefix of another it
  1052. // will match the longer piece.
  1053. shortPieces.sort(cmpLenRev);
  1054. longPieces.sort(cmpLenRev);
  1055. mixedPieces.sort(cmpLenRev);
  1056. for (i = 0; i < 12; i++) {
  1057. shortPieces[i] = regexEscape(shortPieces[i]);
  1058. longPieces[i] = regexEscape(longPieces[i]);
  1059. }
  1060. for (i = 0; i < 24; i++) {
  1061. mixedPieces[i] = regexEscape(mixedPieces[i]);
  1062. }
  1063. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  1064. this._monthsShortRegex = this._monthsRegex;
  1065. this._monthsStrictRegex = new RegExp(
  1066. '^(' + longPieces.join('|') + ')',
  1067. 'i'
  1068. );
  1069. this._monthsShortStrictRegex = new RegExp(
  1070. '^(' + shortPieces.join('|') + ')',
  1071. 'i'
  1072. );
  1073. }
  1074. // FORMATTING
  1075. addFormatToken('Y', 0, 0, function () {
  1076. var y = this.year();
  1077. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  1078. });
  1079. addFormatToken(0, ['YY', 2], 0, function () {
  1080. return this.year() % 100;
  1081. });
  1082. addFormatToken(0, ['YYYY', 4], 0, 'year');
  1083. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  1084. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  1085. // ALIASES
  1086. addUnitAlias('year', 'y');
  1087. // PRIORITIES
  1088. addUnitPriority('year', 1);
  1089. // PARSING
  1090. addRegexToken('Y', matchSigned);
  1091. addRegexToken('YY', match1to2, match2);
  1092. addRegexToken('YYYY', match1to4, match4);
  1093. addRegexToken('YYYYY', match1to6, match6);
  1094. addRegexToken('YYYYYY', match1to6, match6);
  1095. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  1096. addParseToken('YYYY', function (input, array) {
  1097. array[YEAR] =
  1098. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  1099. });
  1100. addParseToken('YY', function (input, array) {
  1101. array[YEAR] = hooks.parseTwoDigitYear(input);
  1102. });
  1103. addParseToken('Y', function (input, array) {
  1104. array[YEAR] = parseInt(input, 10);
  1105. });
  1106. // HELPERS
  1107. function daysInYear(year) {
  1108. return isLeapYear(year) ? 366 : 365;
  1109. }
  1110. // HOOKS
  1111. hooks.parseTwoDigitYear = function (input) {
  1112. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  1113. };
  1114. // MOMENTS
  1115. var getSetYear = makeGetSet('FullYear', true);
  1116. function getIsLeapYear() {
  1117. return isLeapYear(this.year());
  1118. }
  1119. function createDate(y, m, d, h, M, s, ms) {
  1120. // can't just apply() to create a date:
  1121. // https://stackoverflow.com/q/181348
  1122. var date;
  1123. // the date constructor remaps years 0-99 to 1900-1999
  1124. if (y < 100 && y >= 0) {
  1125. // preserve leap years using a full 400 year cycle, then reset
  1126. date = new Date(y + 400, m, d, h, M, s, ms);
  1127. if (isFinite(date.getFullYear())) {
  1128. date.setFullYear(y);
  1129. }
  1130. } else {
  1131. date = new Date(y, m, d, h, M, s, ms);
  1132. }
  1133. return date;
  1134. }
  1135. function createUTCDate(y) {
  1136. var date, args;
  1137. // the Date.UTC function remaps years 0-99 to 1900-1999
  1138. if (y < 100 && y >= 0) {
  1139. args = Array.prototype.slice.call(arguments);
  1140. // preserve leap years using a full 400 year cycle, then reset
  1141. args[0] = y + 400;
  1142. date = new Date(Date.UTC.apply(null, args));
  1143. if (isFinite(date.getUTCFullYear())) {
  1144. date.setUTCFullYear(y);
  1145. }
  1146. } else {
  1147. date = new Date(Date.UTC.apply(null, arguments));
  1148. }
  1149. return date;
  1150. }
  1151. // start-of-first-week - start-of-year
  1152. function firstWeekOffset(year, dow, doy) {
  1153. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  1154. fwd = 7 + dow - doy,
  1155. // first-week day local weekday -- which local weekday is fwd
  1156. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  1157. return -fwdlw + fwd - 1;
  1158. }
  1159. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  1160. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  1161. var localWeekday = (7 + weekday - dow) % 7,
  1162. weekOffset = firstWeekOffset(year, dow, doy),
  1163. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  1164. resYear,
  1165. resDayOfYear;
  1166. if (dayOfYear <= 0) {
  1167. resYear = year - 1;
  1168. resDayOfYear = daysInYear(resYear) + dayOfYear;
  1169. } else if (dayOfYear > daysInYear(year)) {
  1170. resYear = year + 1;
  1171. resDayOfYear = dayOfYear - daysInYear(year);
  1172. } else {
  1173. resYear = year;
  1174. resDayOfYear = dayOfYear;
  1175. }
  1176. return {
  1177. year: resYear,
  1178. dayOfYear: resDayOfYear,
  1179. };
  1180. }
  1181. function weekOfYear(mom, dow, doy) {
  1182. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  1183. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  1184. resWeek,
  1185. resYear;
  1186. if (week < 1) {
  1187. resYear = mom.year() - 1;
  1188. resWeek = week + weeksInYear(resYear, dow, doy);
  1189. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  1190. resWeek = week - weeksInYear(mom.year(), dow, doy);
  1191. resYear = mom.year() + 1;
  1192. } else {
  1193. resYear = mom.year();
  1194. resWeek = week;
  1195. }
  1196. return {
  1197. week: resWeek,
  1198. year: resYear,
  1199. };
  1200. }
  1201. function weeksInYear(year, dow, doy) {
  1202. var weekOffset = firstWeekOffset(year, dow, doy),
  1203. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  1204. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  1205. }
  1206. // FORMATTING
  1207. addFormatToken('w', ['ww', 2], 'wo', 'week');
  1208. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  1209. // ALIASES
  1210. addUnitAlias('week', 'w');
  1211. addUnitAlias('isoWeek', 'W');
  1212. // PRIORITIES
  1213. addUnitPriority('week', 5);
  1214. addUnitPriority('isoWeek', 5);
  1215. // PARSING
  1216. addRegexToken('w', match1to2);
  1217. addRegexToken('ww', match1to2, match2);
  1218. addRegexToken('W', match1to2);
  1219. addRegexToken('WW', match1to2, match2);
  1220. addWeekParseToken(
  1221. ['w', 'ww', 'W', 'WW'],
  1222. function (input, week, config, token) {
  1223. week[token.substr(0, 1)] = toInt(input);
  1224. }
  1225. );
  1226. // HELPERS
  1227. // LOCALES
  1228. function localeWeek(mom) {
  1229. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  1230. }
  1231. var defaultLocaleWeek = {
  1232. dow: 0, // Sunday is the first day of the week.
  1233. doy: 6, // The week that contains Jan 6th is the first week of the year.
  1234. };
  1235. function localeFirstDayOfWeek() {
  1236. return this._week.dow;
  1237. }
  1238. function localeFirstDayOfYear() {
  1239. return this._week.doy;
  1240. }
  1241. // MOMENTS
  1242. function getSetWeek(input) {
  1243. var week = this.localeData().week(this);
  1244. return input == null ? week : this.add((input - week) * 7, 'd');
  1245. }
  1246. function getSetISOWeek(input) {
  1247. var week = weekOfYear(this, 1, 4).week;
  1248. return input == null ? week : this.add((input - week) * 7, 'd');
  1249. }
  1250. // FORMATTING
  1251. addFormatToken('d', 0, 'do', 'day');
  1252. addFormatToken('dd', 0, 0, function (format) {
  1253. return this.localeData().weekdaysMin(this, format);
  1254. });
  1255. addFormatToken('ddd', 0, 0, function (format) {
  1256. return this.localeData().weekdaysShort(this, format);
  1257. });
  1258. addFormatToken('dddd', 0, 0, function (format) {
  1259. return this.localeData().weekdays(this, format);
  1260. });
  1261. addFormatToken('e', 0, 0, 'weekday');
  1262. addFormatToken('E', 0, 0, 'isoWeekday');
  1263. // ALIASES
  1264. addUnitAlias('day', 'd');
  1265. addUnitAlias('weekday', 'e');
  1266. addUnitAlias('isoWeekday', 'E');
  1267. // PRIORITY
  1268. addUnitPriority('day', 11);
  1269. addUnitPriority('weekday', 11);
  1270. addUnitPriority('isoWeekday', 11);
  1271. // PARSING
  1272. addRegexToken('d', match1to2);
  1273. addRegexToken('e', match1to2);
  1274. addRegexToken('E', match1to2);
  1275. addRegexToken('dd', function (isStrict, locale) {
  1276. return locale.weekdaysMinRegex(isStrict);
  1277. });
  1278. addRegexToken('ddd', function (isStrict, locale) {
  1279. return locale.weekdaysShortRegex(isStrict);
  1280. });
  1281. addRegexToken('dddd', function (isStrict, locale) {
  1282. return locale.weekdaysRegex(isStrict);
  1283. });
  1284. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  1285. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  1286. // if we didn't get a weekday name, mark the date as invalid
  1287. if (weekday != null) {
  1288. week.d = weekday;
  1289. } else {
  1290. getParsingFlags(config).invalidWeekday = input;
  1291. }
  1292. });
  1293. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  1294. week[token] = toInt(input);
  1295. });
  1296. // HELPERS
  1297. function parseWeekday(input, locale) {
  1298. if (typeof input !== 'string') {
  1299. return input;
  1300. }
  1301. if (!isNaN(input)) {
  1302. return parseInt(input, 10);
  1303. }
  1304. input = locale.weekdaysParse(input);
  1305. if (typeof input === 'number') {
  1306. return input;
  1307. }
  1308. return null;
  1309. }
  1310. function parseIsoWeekday(input, locale) {
  1311. if (typeof input === 'string') {
  1312. return locale.weekdaysParse(input) % 7 || 7;
  1313. }
  1314. return isNaN(input) ? null : input;
  1315. }
  1316. // LOCALES
  1317. function shiftWeekdays(ws, n) {
  1318. return ws.slice(n, 7).concat(ws.slice(0, n));
  1319. }
  1320. var defaultLocaleWeekdays =
  1321. 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  1322. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  1323. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  1324. defaultWeekdaysRegex = matchWord,
  1325. defaultWeekdaysShortRegex = matchWord,
  1326. defaultWeekdaysMinRegex = matchWord;
  1327. function localeWeekdays(m, format) {
  1328. var weekdays = isArray(this._weekdays)
  1329. ? this._weekdays
  1330. : this._weekdays[
  1331. m && m !== true && this._weekdays.isFormat.test(format)
  1332. ? 'format'
  1333. : 'standalone'
  1334. ];
  1335. return m === true
  1336. ? shiftWeekdays(weekdays, this._week.dow)
  1337. : m
  1338. ? weekdays[m.day()]
  1339. : weekdays;
  1340. }
  1341. function localeWeekdaysShort(m) {
  1342. return m === true
  1343. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  1344. : m
  1345. ? this._weekdaysShort[m.day()]
  1346. : this._weekdaysShort;
  1347. }
  1348. function localeWeekdaysMin(m) {
  1349. return m === true
  1350. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  1351. : m
  1352. ? this._weekdaysMin[m.day()]
  1353. : this._weekdaysMin;
  1354. }
  1355. function handleStrictParse$1(weekdayName, format, strict) {
  1356. var i,
  1357. ii,
  1358. mom,
  1359. llc = weekdayName.toLocaleLowerCase();
  1360. if (!this._weekdaysParse) {
  1361. this._weekdaysParse = [];
  1362. this._shortWeekdaysParse = [];
  1363. this._minWeekdaysParse = [];
  1364. for (i = 0; i < 7; ++i) {
  1365. mom = createUTC([2000, 1]).day(i);
  1366. this._minWeekdaysParse[i] = this.weekdaysMin(
  1367. mom,
  1368. ''
  1369. ).toLocaleLowerCase();
  1370. this._shortWeekdaysParse[i] = this.weekdaysShort(
  1371. mom,
  1372. ''
  1373. ).toLocaleLowerCase();
  1374. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  1375. }
  1376. }
  1377. if (strict) {
  1378. if (format === 'dddd') {
  1379. ii = indexOf.call(this._weekdaysParse, llc);
  1380. return ii !== -1 ? ii : null;
  1381. } else if (format === 'ddd') {
  1382. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1383. return ii !== -1 ? ii : null;
  1384. } else {
  1385. ii = indexOf.call(this._minWeekdaysParse, llc);
  1386. return ii !== -1 ? ii : null;
  1387. }
  1388. } else {
  1389. if (format === 'dddd') {
  1390. ii = indexOf.call(this._weekdaysParse, llc);
  1391. if (ii !== -1) {
  1392. return ii;
  1393. }
  1394. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1395. if (ii !== -1) {
  1396. return ii;
  1397. }
  1398. ii = indexOf.call(this._minWeekdaysParse, llc);
  1399. return ii !== -1 ? ii : null;
  1400. } else if (format === 'ddd') {
  1401. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1402. if (ii !== -1) {
  1403. return ii;
  1404. }
  1405. ii = indexOf.call(this._weekdaysParse, llc);
  1406. if (ii !== -1) {
  1407. return ii;
  1408. }
  1409. ii = indexOf.call(this._minWeekdaysParse, llc);
  1410. return ii !== -1 ? ii : null;
  1411. } else {
  1412. ii = indexOf.call(this._minWeekdaysParse, llc);
  1413. if (ii !== -1) {
  1414. return ii;
  1415. }
  1416. ii = indexOf.call(this._weekdaysParse, llc);
  1417. if (ii !== -1) {
  1418. return ii;
  1419. }
  1420. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1421. return ii !== -1 ? ii : null;
  1422. }
  1423. }
  1424. }
  1425. function localeWeekdaysParse(weekdayName, format, strict) {
  1426. var i, mom, regex;
  1427. if (this._weekdaysParseExact) {
  1428. return handleStrictParse$1.call(this, weekdayName, format, strict);
  1429. }
  1430. if (!this._weekdaysParse) {
  1431. this._weekdaysParse = [];
  1432. this._minWeekdaysParse = [];
  1433. this._shortWeekdaysParse = [];
  1434. this._fullWeekdaysParse = [];
  1435. }
  1436. for (i = 0; i < 7; i++) {
  1437. // make the regex if we don't have it already
  1438. mom = createUTC([2000, 1]).day(i);
  1439. if (strict && !this._fullWeekdaysParse[i]) {
  1440. this._fullWeekdaysParse[i] = new RegExp(
  1441. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  1442. 'i'
  1443. );
  1444. this._shortWeekdaysParse[i] = new RegExp(
  1445. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  1446. 'i'
  1447. );
  1448. this._minWeekdaysParse[i] = new RegExp(
  1449. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  1450. 'i'
  1451. );
  1452. }
  1453. if (!this._weekdaysParse[i]) {
  1454. regex =
  1455. '^' +
  1456. this.weekdays(mom, '') +
  1457. '|^' +
  1458. this.weekdaysShort(mom, '') +
  1459. '|^' +
  1460. this.weekdaysMin(mom, '');
  1461. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  1462. }
  1463. // test the regex
  1464. if (
  1465. strict &&
  1466. format === 'dddd' &&
  1467. this._fullWeekdaysParse[i].test(weekdayName)
  1468. ) {
  1469. return i;
  1470. } else if (
  1471. strict &&
  1472. format === 'ddd' &&
  1473. this._shortWeekdaysParse[i].test(weekdayName)
  1474. ) {
  1475. return i;
  1476. } else if (
  1477. strict &&
  1478. format === 'dd' &&
  1479. this._minWeekdaysParse[i].test(weekdayName)
  1480. ) {
  1481. return i;
  1482. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  1483. return i;
  1484. }
  1485. }
  1486. }
  1487. // MOMENTS
  1488. function getSetDayOfWeek(input) {
  1489. if (!this.isValid()) {
  1490. return input != null ? this : NaN;
  1491. }
  1492. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  1493. if (input != null) {
  1494. input = parseWeekday(input, this.localeData());
  1495. return this.add(input - day, 'd');
  1496. } else {
  1497. return day;
  1498. }
  1499. }
  1500. function getSetLocaleDayOfWeek(input) {
  1501. if (!this.isValid()) {
  1502. return input != null ? this : NaN;
  1503. }
  1504. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  1505. return input == null ? weekday : this.add(input - weekday, 'd');
  1506. }
  1507. function getSetISODayOfWeek(input) {
  1508. if (!this.isValid()) {
  1509. return input != null ? this : NaN;
  1510. }
  1511. // behaves the same as moment#day except
  1512. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  1513. // as a setter, sunday should belong to the previous week.
  1514. if (input != null) {
  1515. var weekday = parseIsoWeekday(input, this.localeData());
  1516. return this.day(this.day() % 7 ? weekday : weekday - 7);
  1517. } else {
  1518. return this.day() || 7;
  1519. }
  1520. }
  1521. function weekdaysRegex(isStrict) {
  1522. if (this._weekdaysParseExact) {
  1523. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1524. computeWeekdaysParse.call(this);
  1525. }
  1526. if (isStrict) {
  1527. return this._weekdaysStrictRegex;
  1528. } else {
  1529. return this._weekdaysRegex;
  1530. }
  1531. } else {
  1532. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1533. this._weekdaysRegex = defaultWeekdaysRegex;
  1534. }
  1535. return this._weekdaysStrictRegex && isStrict
  1536. ? this._weekdaysStrictRegex
  1537. : this._weekdaysRegex;
  1538. }
  1539. }
  1540. function weekdaysShortRegex(isStrict) {
  1541. if (this._weekdaysParseExact) {
  1542. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1543. computeWeekdaysParse.call(this);
  1544. }
  1545. if (isStrict) {
  1546. return this._weekdaysShortStrictRegex;
  1547. } else {
  1548. return this._weekdaysShortRegex;
  1549. }
  1550. } else {
  1551. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  1552. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  1553. }
  1554. return this._weekdaysShortStrictRegex && isStrict
  1555. ? this._weekdaysShortStrictRegex
  1556. : this._weekdaysShortRegex;
  1557. }
  1558. }
  1559. function weekdaysMinRegex(isStrict) {
  1560. if (this._weekdaysParseExact) {
  1561. if (!hasOwnProp(this, '_weekdaysRegex')) {
  1562. computeWeekdaysParse.call(this);
  1563. }
  1564. if (isStrict) {
  1565. return this._weekdaysMinStrictRegex;
  1566. } else {
  1567. return this._weekdaysMinRegex;
  1568. }
  1569. } else {
  1570. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  1571. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  1572. }
  1573. return this._weekdaysMinStrictRegex && isStrict
  1574. ? this._weekdaysMinStrictRegex
  1575. : this._weekdaysMinRegex;
  1576. }
  1577. }
  1578. function computeWeekdaysParse() {
  1579. function cmpLenRev(a, b) {
  1580. return b.length - a.length;
  1581. }
  1582. var minPieces = [],
  1583. shortPieces = [],
  1584. longPieces = [],
  1585. mixedPieces = [],
  1586. i,
  1587. mom,
  1588. minp,
  1589. shortp,
  1590. longp;
  1591. for (i = 0; i < 7; i++) {
  1592. // make the regex if we don't have it already
  1593. mom = createUTC([2000, 1]).day(i);
  1594. minp = regexEscape(this.weekdaysMin(mom, ''));
  1595. shortp = regexEscape(this.weekdaysShort(mom, ''));
  1596. longp = regexEscape(this.weekdays(mom, ''));
  1597. minPieces.push(minp);
  1598. shortPieces.push(shortp);
  1599. longPieces.push(longp);
  1600. mixedPieces.push(minp);
  1601. mixedPieces.push(shortp);
  1602. mixedPieces.push(longp);
  1603. }
  1604. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  1605. // will match the longer piece.
  1606. minPieces.sort(cmpLenRev);
  1607. shortPieces.sort(cmpLenRev);
  1608. longPieces.sort(cmpLenRev);
  1609. mixedPieces.sort(cmpLenRev);
  1610. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  1611. this._weekdaysShortRegex = this._weekdaysRegex;
  1612. this._weekdaysMinRegex = this._weekdaysRegex;
  1613. this._weekdaysStrictRegex = new RegExp(
  1614. '^(' + longPieces.join('|') + ')',
  1615. 'i'
  1616. );
  1617. this._weekdaysShortStrictRegex = new RegExp(
  1618. '^(' + shortPieces.join('|') + ')',
  1619. 'i'
  1620. );
  1621. this._weekdaysMinStrictRegex = new RegExp(
  1622. '^(' + minPieces.join('|') + ')',
  1623. 'i'
  1624. );
  1625. }
  1626. // FORMATTING
  1627. function hFormat() {
  1628. return this.hours() % 12 || 12;
  1629. }
  1630. function kFormat() {
  1631. return this.hours() || 24;
  1632. }
  1633. addFormatToken('H', ['HH', 2], 0, 'hour');
  1634. addFormatToken('h', ['hh', 2], 0, hFormat);
  1635. addFormatToken('k', ['kk', 2], 0, kFormat);
  1636. addFormatToken('hmm', 0, 0, function () {
  1637. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  1638. });
  1639. addFormatToken('hmmss', 0, 0, function () {
  1640. return (
  1641. '' +
  1642. hFormat.apply(this) +
  1643. zeroFill(this.minutes(), 2) +
  1644. zeroFill(this.seconds(), 2)
  1645. );
  1646. });
  1647. addFormatToken('Hmm', 0, 0, function () {
  1648. return '' + this.hours() + zeroFill(this.minutes(), 2);
  1649. });
  1650. addFormatToken('Hmmss', 0, 0, function () {
  1651. return (
  1652. '' +
  1653. this.hours() +
  1654. zeroFill(this.minutes(), 2) +
  1655. zeroFill(this.seconds(), 2)
  1656. );
  1657. });
  1658. function meridiem(token, lowercase) {
  1659. addFormatToken(token, 0, 0, function () {
  1660. return this.localeData().meridiem(
  1661. this.hours(),
  1662. this.minutes(),
  1663. lowercase
  1664. );
  1665. });
  1666. }
  1667. meridiem('a', true);
  1668. meridiem('A', false);
  1669. // ALIASES
  1670. addUnitAlias('hour', 'h');
  1671. // PRIORITY
  1672. addUnitPriority('hour', 13);
  1673. // PARSING
  1674. function matchMeridiem(isStrict, locale) {
  1675. return locale._meridiemParse;
  1676. }
  1677. addRegexToken('a', matchMeridiem);
  1678. addRegexToken('A', matchMeridiem);
  1679. addRegexToken('H', match1to2);
  1680. addRegexToken('h', match1to2);
  1681. addRegexToken('k', match1to2);
  1682. addRegexToken('HH', match1to2, match2);
  1683. addRegexToken('hh', match1to2, match2);
  1684. addRegexToken('kk', match1to2, match2);
  1685. addRegexToken('hmm', match3to4);
  1686. addRegexToken('hmmss', match5to6);
  1687. addRegexToken('Hmm', match3to4);
  1688. addRegexToken('Hmmss', match5to6);
  1689. addParseToken(['H', 'HH'], HOUR);
  1690. addParseToken(['k', 'kk'], function (input, array, config) {
  1691. var kInput = toInt(input);
  1692. array[HOUR] = kInput === 24 ? 0 : kInput;
  1693. });
  1694. addParseToken(['a', 'A'], function (input, array, config) {
  1695. config._isPm = config._locale.isPM(input);
  1696. config._meridiem = input;
  1697. });
  1698. addParseToken(['h', 'hh'], function (input, array, config) {
  1699. array[HOUR] = toInt(input);
  1700. getParsingFlags(config).bigHour = true;
  1701. });
  1702. addParseToken('hmm', function (input, array, config) {
  1703. var pos = input.length - 2;
  1704. array[HOUR] = toInt(input.substr(0, pos));
  1705. array[MINUTE] = toInt(input.substr(pos));
  1706. getParsingFlags(config).bigHour = true;
  1707. });
  1708. addParseToken('hmmss', function (input, array, config) {
  1709. var pos1 = input.length - 4,
  1710. pos2 = input.length - 2;
  1711. array[HOUR] = toInt(input.substr(0, pos1));
  1712. array[MINUTE] = toInt(input.substr(pos1, 2));
  1713. array[SECOND] = toInt(input.substr(pos2));
  1714. getParsingFlags(config).bigHour = true;
  1715. });
  1716. addParseToken('Hmm', function (input, array, config) {
  1717. var pos = input.length - 2;
  1718. array[HOUR] = toInt(input.substr(0, pos));
  1719. array[MINUTE] = toInt(input.substr(pos));
  1720. });
  1721. addParseToken('Hmmss', function (input, array, config) {
  1722. var pos1 = input.length - 4,
  1723. pos2 = input.length - 2;
  1724. array[HOUR] = toInt(input.substr(0, pos1));
  1725. array[MINUTE] = toInt(input.substr(pos1, 2));
  1726. array[SECOND] = toInt(input.substr(pos2));
  1727. });
  1728. // LOCALES
  1729. function localeIsPM(input) {
  1730. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  1731. // Using charAt should be more compatible.
  1732. return (input + '').toLowerCase().charAt(0) === 'p';
  1733. }
  1734. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  1735. // Setting the hour should keep the time, because the user explicitly
  1736. // specified which hour they want. So trying to maintain the same hour (in
  1737. // a new timezone) makes sense. Adding/subtracting hours does not follow
  1738. // this rule.
  1739. getSetHour = makeGetSet('Hours', true);
  1740. function localeMeridiem(hours, minutes, isLower) {
  1741. if (hours > 11) {
  1742. return isLower ? 'pm' : 'PM';
  1743. } else {
  1744. return isLower ? 'am' : 'AM';
  1745. }
  1746. }
  1747. var baseConfig = {
  1748. calendar: defaultCalendar,
  1749. longDateFormat: defaultLongDateFormat,
  1750. invalidDate: defaultInvalidDate,
  1751. ordinal: defaultOrdinal,
  1752. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  1753. relativeTime: defaultRelativeTime,
  1754. months: defaultLocaleMonths,
  1755. monthsShort: defaultLocaleMonthsShort,
  1756. week: defaultLocaleWeek,
  1757. weekdays: defaultLocaleWeekdays,
  1758. weekdaysMin: defaultLocaleWeekdaysMin,
  1759. weekdaysShort: defaultLocaleWeekdaysShort,
  1760. meridiemParse: defaultLocaleMeridiemParse,
  1761. };
  1762. // internal storage for locale config files
  1763. var locales = {},
  1764. localeFamilies = {},
  1765. globalLocale;
  1766. function commonPrefix(arr1, arr2) {
  1767. var i,
  1768. minl = Math.min(arr1.length, arr2.length);
  1769. for (i = 0; i < minl; i += 1) {
  1770. if (arr1[i] !== arr2[i]) {
  1771. return i;
  1772. }
  1773. }
  1774. return minl;
  1775. }
  1776. function normalizeLocale(key) {
  1777. return key ? key.toLowerCase().replace('_', '-') : key;
  1778. }
  1779. // pick the locale from the array
  1780. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  1781. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  1782. function chooseLocale(names) {
  1783. var i = 0,
  1784. j,
  1785. next,
  1786. locale,
  1787. split;
  1788. while (i < names.length) {
  1789. split = normalizeLocale(names[i]).split('-');
  1790. j = split.length;
  1791. next = normalizeLocale(names[i + 1]);
  1792. next = next ? next.split('-') : null;
  1793. while (j > 0) {
  1794. locale = loadLocale(split.slice(0, j).join('-'));
  1795. if (locale) {
  1796. return locale;
  1797. }
  1798. if (
  1799. next &&
  1800. next.length >= j &&
  1801. commonPrefix(split, next) >= j - 1
  1802. ) {
  1803. //the next array item is better than a shallower substring of this one
  1804. break;
  1805. }
  1806. j--;
  1807. }
  1808. i++;
  1809. }
  1810. return globalLocale;
  1811. }
  1812. function isLocaleNameSane(name) {
  1813. // Prevent names that look like filesystem paths, i.e contain '/' or '\'
  1814. return name.match('^[^/\\\\]*$') != null;
  1815. }
  1816. function loadLocale(name) {
  1817. var oldLocale = null,
  1818. aliasedRequire;
  1819. // TODO: Find a better way to register and load all the locales in Node
  1820. if (
  1821. locales[name] === undefined &&
  1822. typeof module !== 'undefined' &&
  1823. module &&
  1824. module.exports &&
  1825. isLocaleNameSane(name)
  1826. ) {
  1827. try {
  1828. oldLocale = globalLocale._abbr;
  1829. aliasedRequire = require;
  1830. aliasedRequire('./locale/' + name);
  1831. getSetGlobalLocale(oldLocale);
  1832. } catch (e) {
  1833. // mark as not found to avoid repeating expensive file require call causing high CPU
  1834. // when trying to find en-US, en_US, en-us for every format call
  1835. locales[name] = null; // null means not found
  1836. }
  1837. }
  1838. return locales[name];
  1839. }
  1840. // This function will load locale and then set the global locale. If
  1841. // no arguments are passed in, it will simply return the current global
  1842. // locale key.
  1843. function getSetGlobalLocale(key, values) {
  1844. var data;
  1845. if (key) {
  1846. if (isUndefined(values)) {
  1847. data = getLocale(key);
  1848. } else {
  1849. data = defineLocale(key, values);
  1850. }
  1851. if (data) {
  1852. // moment.duration._locale = moment._locale = data;
  1853. globalLocale = data;
  1854. } else {
  1855. if (typeof console !== 'undefined' && console.warn) {
  1856. //warn user if arguments are passed but the locale could not be set
  1857. console.warn(
  1858. 'Locale ' + key + ' not found. Did you forget to load it?'
  1859. );
  1860. }
  1861. }
  1862. }
  1863. return globalLocale._abbr;
  1864. }
  1865. function defineLocale(name, config) {
  1866. if (config !== null) {
  1867. var locale,
  1868. parentConfig = baseConfig;
  1869. config.abbr = name;
  1870. if (locales[name] != null) {
  1871. deprecateSimple(
  1872. 'defineLocaleOverride',
  1873. 'use moment.updateLocale(localeName, config) to change ' +
  1874. 'an existing locale. moment.defineLocale(localeName, ' +
  1875. 'config) should only be used for creating a new locale ' +
  1876. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  1877. );
  1878. parentConfig = locales[name]._config;
  1879. } else if (config.parentLocale != null) {
  1880. if (locales[config.parentLocale] != null) {
  1881. parentConfig = locales[config.parentLocale]._config;
  1882. } else {
  1883. locale = loadLocale(config.parentLocale);
  1884. if (locale != null) {
  1885. parentConfig = locale._config;
  1886. } else {
  1887. if (!localeFamilies[config.parentLocale]) {
  1888. localeFamilies[config.parentLocale] = [];
  1889. }
  1890. localeFamilies[config.parentLocale].push({
  1891. name: name,
  1892. config: config,
  1893. });
  1894. return null;
  1895. }
  1896. }
  1897. }
  1898. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  1899. if (localeFamilies[name]) {
  1900. localeFamilies[name].forEach(function (x) {
  1901. defineLocale(x.name, x.config);
  1902. });
  1903. }
  1904. // backwards compat for now: also set the locale
  1905. // make sure we set the locale AFTER all child locales have been
  1906. // created, so we won't end up with the child locale set.
  1907. getSetGlobalLocale(name);
  1908. return locales[name];
  1909. } else {
  1910. // useful for testing
  1911. delete locales[name];
  1912. return null;
  1913. }
  1914. }
  1915. function updateLocale(name, config) {
  1916. if (config != null) {
  1917. var locale,
  1918. tmpLocale,
  1919. parentConfig = baseConfig;
  1920. if (locales[name] != null && locales[name].parentLocale != null) {
  1921. // Update existing child locale in-place to avoid memory-leaks
  1922. locales[name].set(mergeConfigs(locales[name]._config, config));
  1923. } else {
  1924. // MERGE
  1925. tmpLocale = loadLocale(name);
  1926. if (tmpLocale != null) {
  1927. parentConfig = tmpLocale._config;
  1928. }
  1929. config = mergeConfigs(parentConfig, config);
  1930. if (tmpLocale == null) {
  1931. // updateLocale is called for creating a new locale
  1932. // Set abbr so it will have a name (getters return
  1933. // undefined otherwise).
  1934. config.abbr = name;
  1935. }
  1936. locale = new Locale(config);
  1937. locale.parentLocale = locales[name];
  1938. locales[name] = locale;
  1939. }
  1940. // backwards compat for now: also set the locale
  1941. getSetGlobalLocale(name);
  1942. } else {
  1943. // pass null for config to unupdate, useful for tests
  1944. if (locales[name] != null) {
  1945. if (locales[name].parentLocale != null) {
  1946. locales[name] = locales[name].parentLocale;
  1947. if (name === getSetGlobalLocale()) {
  1948. getSetGlobalLocale(name);
  1949. }
  1950. } else if (locales[name] != null) {
  1951. delete locales[name];
  1952. }
  1953. }
  1954. }
  1955. return locales[name];
  1956. }
  1957. // returns locale data
  1958. function getLocale(key) {
  1959. var locale;
  1960. if (key && key._locale && key._locale._abbr) {
  1961. key = key._locale._abbr;
  1962. }
  1963. if (!key) {
  1964. return globalLocale;
  1965. }
  1966. if (!isArray(key)) {
  1967. //short-circuit everything else
  1968. locale = loadLocale(key);
  1969. if (locale) {
  1970. return locale;
  1971. }
  1972. key = [key];
  1973. }
  1974. return chooseLocale(key);
  1975. }
  1976. function listLocales() {
  1977. return keys(locales);
  1978. }
  1979. function checkOverflow(m) {
  1980. var overflow,
  1981. a = m._a;
  1982. if (a && getParsingFlags(m).overflow === -2) {
  1983. overflow =
  1984. a[MONTH] < 0 || a[MONTH] > 11
  1985. ? MONTH
  1986. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  1987. ? DATE
  1988. : a[HOUR] < 0 ||
  1989. a[HOUR] > 24 ||
  1990. (a[HOUR] === 24 &&
  1991. (a[MINUTE] !== 0 ||
  1992. a[SECOND] !== 0 ||
  1993. a[MILLISECOND] !== 0))
  1994. ? HOUR
  1995. : a[MINUTE] < 0 || a[MINUTE] > 59
  1996. ? MINUTE
  1997. : a[SECOND] < 0 || a[SECOND] > 59
  1998. ? SECOND
  1999. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  2000. ? MILLISECOND
  2001. : -1;
  2002. if (
  2003. getParsingFlags(m)._overflowDayOfYear &&
  2004. (overflow < YEAR || overflow > DATE)
  2005. ) {
  2006. overflow = DATE;
  2007. }
  2008. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  2009. overflow = WEEK;
  2010. }
  2011. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  2012. overflow = WEEKDAY;
  2013. }
  2014. getParsingFlags(m).overflow = overflow;
  2015. }
  2016. return m;
  2017. }
  2018. // iso 8601 regex
  2019. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  2020. var extendedIsoRegex =
  2021. /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  2022. basicIsoRegex =
  2023. /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  2024. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  2025. isoDates = [
  2026. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  2027. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  2028. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  2029. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  2030. ['YYYY-DDD', /\d{4}-\d{3}/],
  2031. ['YYYY-MM', /\d{4}-\d\d/, false],
  2032. ['YYYYYYMMDD', /[+-]\d{10}/],
  2033. ['YYYYMMDD', /\d{8}/],
  2034. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  2035. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  2036. ['YYYYDDD', /\d{7}/],
  2037. ['YYYYMM', /\d{6}/, false],
  2038. ['YYYY', /\d{4}/, false],
  2039. ],
  2040. // iso time formats and regexes
  2041. isoTimes = [
  2042. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  2043. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  2044. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  2045. ['HH:mm', /\d\d:\d\d/],
  2046. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  2047. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  2048. ['HHmmss', /\d\d\d\d\d\d/],
  2049. ['HHmm', /\d\d\d\d/],
  2050. ['HH', /\d\d/],
  2051. ],
  2052. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  2053. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  2054. rfc2822 =
  2055. /^(?:(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{4}))$/,
  2056. obsOffsets = {
  2057. UT: 0,
  2058. GMT: 0,
  2059. EDT: -4 * 60,
  2060. EST: -5 * 60,
  2061. CDT: -5 * 60,
  2062. CST: -6 * 60,
  2063. MDT: -6 * 60,
  2064. MST: -7 * 60,
  2065. PDT: -7 * 60,
  2066. PST: -8 * 60,
  2067. };
  2068. // date from iso format
  2069. function configFromISO(config) {
  2070. var i,
  2071. l,
  2072. string = config._i,
  2073. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  2074. allowTime,
  2075. dateFormat,
  2076. timeFormat,
  2077. tzFormat,
  2078. isoDatesLen = isoDates.length,
  2079. isoTimesLen = isoTimes.length;
  2080. if (match) {
  2081. getParsingFlags(config).iso = true;
  2082. for (i = 0, l = isoDatesLen; i < l; i++) {
  2083. if (isoDates[i][1].exec(match[1])) {
  2084. dateFormat = isoDates[i][0];
  2085. allowTime = isoDates[i][2] !== false;
  2086. break;
  2087. }
  2088. }
  2089. if (dateFormat == null) {
  2090. config._isValid = false;
  2091. return;
  2092. }
  2093. if (match[3]) {
  2094. for (i = 0, l = isoTimesLen; i < l; i++) {
  2095. if (isoTimes[i][1].exec(match[3])) {
  2096. // match[2] should be 'T' or space
  2097. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  2098. break;
  2099. }
  2100. }
  2101. if (timeFormat == null) {
  2102. config._isValid = false;
  2103. return;
  2104. }
  2105. }
  2106. if (!allowTime && timeFormat != null) {
  2107. config._isValid = false;
  2108. return;
  2109. }
  2110. if (match[4]) {
  2111. if (tzRegex.exec(match[4])) {
  2112. tzFormat = 'Z';
  2113. } else {
  2114. config._isValid = false;
  2115. return;
  2116. }
  2117. }
  2118. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  2119. configFromStringAndFormat(config);
  2120. } else {
  2121. config._isValid = false;
  2122. }
  2123. }
  2124. function extractFromRFC2822Strings(
  2125. yearStr,
  2126. monthStr,
  2127. dayStr,
  2128. hourStr,
  2129. minuteStr,
  2130. secondStr
  2131. ) {
  2132. var result = [
  2133. untruncateYear(yearStr),
  2134. defaultLocaleMonthsShort.indexOf(monthStr),
  2135. parseInt(dayStr, 10),
  2136. parseInt(hourStr, 10),
  2137. parseInt(minuteStr, 10),
  2138. ];
  2139. if (secondStr) {
  2140. result.push(parseInt(secondStr, 10));
  2141. }
  2142. return result;
  2143. }
  2144. function untruncateYear(yearStr) {
  2145. var year = parseInt(yearStr, 10);
  2146. if (year <= 49) {
  2147. return 2000 + year;
  2148. } else if (year <= 999) {
  2149. return 1900 + year;
  2150. }
  2151. return year;
  2152. }
  2153. function preprocessRFC2822(s) {
  2154. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  2155. return s
  2156. .replace(/\([^()]*\)|[\n\t]/g, ' ')
  2157. .replace(/(\s\s+)/g, ' ')
  2158. .replace(/^\s\s*/, '')
  2159. .replace(/\s\s*$/, '');
  2160. }
  2161. function checkWeekday(weekdayStr, parsedInput, config) {
  2162. if (weekdayStr) {
  2163. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  2164. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  2165. weekdayActual = new Date(
  2166. parsedInput[0],
  2167. parsedInput[1],
  2168. parsedInput[2]
  2169. ).getDay();
  2170. if (weekdayProvided !== weekdayActual) {
  2171. getParsingFlags(config).weekdayMismatch = true;
  2172. config._isValid = false;
  2173. return false;
  2174. }
  2175. }
  2176. return true;
  2177. }
  2178. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  2179. if (obsOffset) {
  2180. return obsOffsets[obsOffset];
  2181. } else if (militaryOffset) {
  2182. // the only allowed military tz is Z
  2183. return 0;
  2184. } else {
  2185. var hm = parseInt(numOffset, 10),
  2186. m = hm % 100,
  2187. h = (hm - m) / 100;
  2188. return h * 60 + m;
  2189. }
  2190. }
  2191. // date and time from ref 2822 format
  2192. function configFromRFC2822(config) {
  2193. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  2194. parsedArray;
  2195. if (match) {
  2196. parsedArray = extractFromRFC2822Strings(
  2197. match[4],
  2198. match[3],
  2199. match[2],
  2200. match[5],
  2201. match[6],
  2202. match[7]
  2203. );
  2204. if (!checkWeekday(match[1], parsedArray, config)) {
  2205. return;
  2206. }
  2207. config._a = parsedArray;
  2208. config._tzm = calculateOffset(match[8], match[9], match[10]);
  2209. config._d = createUTCDate.apply(null, config._a);
  2210. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  2211. getParsingFlags(config).rfc2822 = true;
  2212. } else {
  2213. config._isValid = false;
  2214. }
  2215. }
  2216. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  2217. function configFromString(config) {
  2218. var matched = aspNetJsonRegex.exec(config._i);
  2219. if (matched !== null) {
  2220. config._d = new Date(+matched[1]);
  2221. return;
  2222. }
  2223. configFromISO(config);
  2224. if (config._isValid === false) {
  2225. delete config._isValid;
  2226. } else {
  2227. return;
  2228. }
  2229. configFromRFC2822(config);
  2230. if (config._isValid === false) {
  2231. delete config._isValid;
  2232. } else {
  2233. return;
  2234. }
  2235. if (config._strict) {
  2236. config._isValid = false;
  2237. } else {
  2238. // Final attempt, use Input Fallback
  2239. hooks.createFromInputFallback(config);
  2240. }
  2241. }
  2242. hooks.createFromInputFallback = deprecate(
  2243. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  2244. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  2245. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  2246. function (config) {
  2247. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  2248. }
  2249. );
  2250. // Pick the first defined of two or three arguments.
  2251. function defaults(a, b, c) {
  2252. if (a != null) {
  2253. return a;
  2254. }
  2255. if (b != null) {
  2256. return b;
  2257. }
  2258. return c;
  2259. }
  2260. function currentDateArray(config) {
  2261. // hooks is actually the exported moment object
  2262. var nowValue = new Date(hooks.now());
  2263. if (config._useUTC) {
  2264. return [
  2265. nowValue.getUTCFullYear(),
  2266. nowValue.getUTCMonth(),
  2267. nowValue.getUTCDate(),
  2268. ];
  2269. }
  2270. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  2271. }
  2272. // convert an array to a date.
  2273. // the array should mirror the parameters below
  2274. // note: all values past the year are optional and will default to the lowest possible value.
  2275. // [year, month, day , hour, minute, second, millisecond]
  2276. function configFromArray(config) {
  2277. var i,
  2278. date,
  2279. input = [],
  2280. currentDate,
  2281. expectedWeekday,
  2282. yearToUse;
  2283. if (config._d) {
  2284. return;
  2285. }
  2286. currentDate = currentDateArray(config);
  2287. //compute day of the year from weeks and weekdays
  2288. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  2289. dayOfYearFromWeekInfo(config);
  2290. }
  2291. //if the day of the year is set, figure out what it is
  2292. if (config._dayOfYear != null) {
  2293. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  2294. if (
  2295. config._dayOfYear > daysInYear(yearToUse) ||
  2296. config._dayOfYear === 0
  2297. ) {
  2298. getParsingFlags(config)._overflowDayOfYear = true;
  2299. }
  2300. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  2301. config._a[MONTH] = date.getUTCMonth();
  2302. config._a[DATE] = date.getUTCDate();
  2303. }
  2304. // Default to current date.
  2305. // * if no year, month, day of month are given, default to today
  2306. // * if day of month is given, default month and year
  2307. // * if month is given, default only year
  2308. // * if year is given, don't default anything
  2309. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  2310. config._a[i] = input[i] = currentDate[i];
  2311. }
  2312. // Zero out whatever was not defaulted, including time
  2313. for (; i < 7; i++) {
  2314. config._a[i] = input[i] =
  2315. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  2316. }
  2317. // Check for 24:00:00.000
  2318. if (
  2319. config._a[HOUR] === 24 &&
  2320. config._a[MINUTE] === 0 &&
  2321. config._a[SECOND] === 0 &&
  2322. config._a[MILLISECOND] === 0
  2323. ) {
  2324. config._nextDay = true;
  2325. config._a[HOUR] = 0;
  2326. }
  2327. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  2328. null,
  2329. input
  2330. );
  2331. expectedWeekday = config._useUTC
  2332. ? config._d.getUTCDay()
  2333. : config._d.getDay();
  2334. // Apply timezone offset from input. The actual utcOffset can be changed
  2335. // with parseZone.
  2336. if (config._tzm != null) {
  2337. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  2338. }
  2339. if (config._nextDay) {
  2340. config._a[HOUR] = 24;
  2341. }
  2342. // check for mismatching day of week
  2343. if (
  2344. config._w &&
  2345. typeof config._w.d !== 'undefined' &&
  2346. config._w.d !== expectedWeekday
  2347. ) {
  2348. getParsingFlags(config).weekdayMismatch = true;
  2349. }
  2350. }
  2351. function dayOfYearFromWeekInfo(config) {
  2352. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  2353. w = config._w;
  2354. if (w.GG != null || w.W != null || w.E != null) {
  2355. dow = 1;
  2356. doy = 4;
  2357. // TODO: We need to take the current isoWeekYear, but that depends on
  2358. // how we interpret now (local, utc, fixed offset). So create
  2359. // a now version of current config (take local/utc/offset flags, and
  2360. // create now).
  2361. weekYear = defaults(
  2362. w.GG,
  2363. config._a[YEAR],
  2364. weekOfYear(createLocal(), 1, 4).year
  2365. );
  2366. week = defaults(w.W, 1);
  2367. weekday = defaults(w.E, 1);
  2368. if (weekday < 1 || weekday > 7) {
  2369. weekdayOverflow = true;
  2370. }
  2371. } else {
  2372. dow = config._locale._week.dow;
  2373. doy = config._locale._week.doy;
  2374. curWeek = weekOfYear(createLocal(), dow, doy);
  2375. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  2376. // Default to current week.
  2377. week = defaults(w.w, curWeek.week);
  2378. if (w.d != null) {
  2379. // weekday -- low day numbers are considered next week
  2380. weekday = w.d;
  2381. if (weekday < 0 || weekday > 6) {
  2382. weekdayOverflow = true;
  2383. }
  2384. } else if (w.e != null) {
  2385. // local weekday -- counting starts from beginning of week
  2386. weekday = w.e + dow;
  2387. if (w.e < 0 || w.e > 6) {
  2388. weekdayOverflow = true;
  2389. }
  2390. } else {
  2391. // default to beginning of week
  2392. weekday = dow;
  2393. }
  2394. }
  2395. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  2396. getParsingFlags(config)._overflowWeeks = true;
  2397. } else if (weekdayOverflow != null) {
  2398. getParsingFlags(config)._overflowWeekday = true;
  2399. } else {
  2400. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  2401. config._a[YEAR] = temp.year;
  2402. config._dayOfYear = temp.dayOfYear;
  2403. }
  2404. }
  2405. // constant that refers to the ISO standard
  2406. hooks.ISO_8601 = function () {};
  2407. // constant that refers to the RFC 2822 form
  2408. hooks.RFC_2822 = function () {};
  2409. // date from string and format string
  2410. function configFromStringAndFormat(config) {
  2411. // TODO: Move this to another part of the creation flow to prevent circular deps
  2412. if (config._f === hooks.ISO_8601) {
  2413. configFromISO(config);
  2414. return;
  2415. }
  2416. if (config._f === hooks.RFC_2822) {
  2417. configFromRFC2822(config);
  2418. return;
  2419. }
  2420. config._a = [];
  2421. getParsingFlags(config).empty = true;
  2422. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  2423. var string = '' + config._i,
  2424. i,
  2425. parsedInput,
  2426. tokens,
  2427. token,
  2428. skipped,
  2429. stringLength = string.length,
  2430. totalParsedInputLength = 0,
  2431. era,
  2432. tokenLen;
  2433. tokens =
  2434. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  2435. tokenLen = tokens.length;
  2436. for (i = 0; i < tokenLen; i++) {
  2437. token = tokens[i];
  2438. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  2439. [])[0];
  2440. if (parsedInput) {
  2441. skipped = string.substr(0, string.indexOf(parsedInput));
  2442. if (skipped.length > 0) {
  2443. getParsingFlags(config).unusedInput.push(skipped);
  2444. }
  2445. string = string.slice(
  2446. string.indexOf(parsedInput) + parsedInput.length
  2447. );
  2448. totalParsedInputLength += parsedInput.length;
  2449. }
  2450. // don't parse if it's not a known token
  2451. if (formatTokenFunctions[token]) {
  2452. if (parsedInput) {
  2453. getParsingFlags(config).empty = false;
  2454. } else {
  2455. getParsingFlags(config).unusedTokens.push(token);
  2456. }
  2457. addTimeToArrayFromToken(token, parsedInput, config);
  2458. } else if (config._strict && !parsedInput) {
  2459. getParsingFlags(config).unusedTokens.push(token);
  2460. }
  2461. }
  2462. // add remaining unparsed input length to the string
  2463. getParsingFlags(config).charsLeftOver =
  2464. stringLength - totalParsedInputLength;
  2465. if (string.length > 0) {
  2466. getParsingFlags(config).unusedInput.push(string);
  2467. }
  2468. // clear _12h flag if hour is <= 12
  2469. if (
  2470. config._a[HOUR] <= 12 &&
  2471. getParsingFlags(config).bigHour === true &&
  2472. config._a[HOUR] > 0
  2473. ) {
  2474. getParsingFlags(config).bigHour = undefined;
  2475. }
  2476. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  2477. getParsingFlags(config).meridiem = config._meridiem;
  2478. // handle meridiem
  2479. config._a[HOUR] = meridiemFixWrap(
  2480. config._locale,
  2481. config._a[HOUR],
  2482. config._meridiem
  2483. );
  2484. // handle era
  2485. era = getParsingFlags(config).era;
  2486. if (era !== null) {
  2487. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  2488. }
  2489. configFromArray(config);
  2490. checkOverflow(config);
  2491. }
  2492. function meridiemFixWrap(locale, hour, meridiem) {
  2493. var isPm;
  2494. if (meridiem == null) {
  2495. // nothing to do
  2496. return hour;
  2497. }
  2498. if (locale.meridiemHour != null) {
  2499. return locale.meridiemHour(hour, meridiem);
  2500. } else if (locale.isPM != null) {
  2501. // Fallback
  2502. isPm = locale.isPM(meridiem);
  2503. if (isPm && hour < 12) {
  2504. hour += 12;
  2505. }
  2506. if (!isPm && hour === 12) {
  2507. hour = 0;
  2508. }
  2509. return hour;
  2510. } else {
  2511. // this is not supposed to happen
  2512. return hour;
  2513. }
  2514. }
  2515. // date from string and array of format strings
  2516. function configFromStringAndArray(config) {
  2517. var tempConfig,
  2518. bestMoment,
  2519. scoreToBeat,
  2520. i,
  2521. currentScore,
  2522. validFormatFound,
  2523. bestFormatIsValid = false,
  2524. configfLen = config._f.length;
  2525. if (configfLen === 0) {
  2526. getParsingFlags(config).invalidFormat = true;
  2527. config._d = new Date(NaN);
  2528. return;
  2529. }
  2530. for (i = 0; i < configfLen; i++) {
  2531. currentScore = 0;
  2532. validFormatFound = false;
  2533. tempConfig = copyConfig({}, config);
  2534. if (config._useUTC != null) {
  2535. tempConfig._useUTC = config._useUTC;
  2536. }
  2537. tempConfig._f = config._f[i];
  2538. configFromStringAndFormat(tempConfig);
  2539. if (isValid(tempConfig)) {
  2540. validFormatFound = true;
  2541. }
  2542. // if there is any input that was not parsed add a penalty for that format
  2543. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  2544. //or tokens
  2545. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  2546. getParsingFlags(tempConfig).score = currentScore;
  2547. if (!bestFormatIsValid) {
  2548. if (
  2549. scoreToBeat == null ||
  2550. currentScore < scoreToBeat ||
  2551. validFormatFound
  2552. ) {
  2553. scoreToBeat = currentScore;
  2554. bestMoment = tempConfig;
  2555. if (validFormatFound) {
  2556. bestFormatIsValid = true;
  2557. }
  2558. }
  2559. } else {
  2560. if (currentScore < scoreToBeat) {
  2561. scoreToBeat = currentScore;
  2562. bestMoment = tempConfig;
  2563. }
  2564. }
  2565. }
  2566. extend(config, bestMoment || tempConfig);
  2567. }
  2568. function configFromObject(config) {
  2569. if (config._d) {
  2570. return;
  2571. }
  2572. var i = normalizeObjectUnits(config._i),
  2573. dayOrDate = i.day === undefined ? i.date : i.day;
  2574. config._a = map(
  2575. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  2576. function (obj) {
  2577. return obj && parseInt(obj, 10);
  2578. }
  2579. );
  2580. configFromArray(config);
  2581. }
  2582. function createFromConfig(config) {
  2583. var res = new Moment(checkOverflow(prepareConfig(config)));
  2584. if (res._nextDay) {
  2585. // Adding is smart enough around DST
  2586. res.add(1, 'd');
  2587. res._nextDay = undefined;
  2588. }
  2589. return res;
  2590. }
  2591. function prepareConfig(config) {
  2592. var input = config._i,
  2593. format = config._f;
  2594. config._locale = config._locale || getLocale(config._l);
  2595. if (input === null || (format === undefined && input === '')) {
  2596. return createInvalid({ nullInput: true });
  2597. }
  2598. if (typeof input === 'string') {
  2599. config._i = input = config._locale.preparse(input);
  2600. }
  2601. if (isMoment(input)) {
  2602. return new Moment(checkOverflow(input));
  2603. } else if (isDate(input)) {
  2604. config._d = input;
  2605. } else if (isArray(format)) {
  2606. configFromStringAndArray(config);
  2607. } else if (format) {
  2608. configFromStringAndFormat(config);
  2609. } else {
  2610. configFromInput(config);
  2611. }
  2612. if (!isValid(config)) {
  2613. config._d = null;
  2614. }
  2615. return config;
  2616. }
  2617. function configFromInput(config) {
  2618. var input = config._i;
  2619. if (isUndefined(input)) {
  2620. config._d = new Date(hooks.now());
  2621. } else if (isDate(input)) {
  2622. config._d = new Date(input.valueOf());
  2623. } else if (typeof input === 'string') {
  2624. configFromString(config);
  2625. } else if (isArray(input)) {
  2626. config._a = map(input.slice(0), function (obj) {
  2627. return parseInt(obj, 10);
  2628. });
  2629. configFromArray(config);
  2630. } else if (isObject(input)) {
  2631. configFromObject(config);
  2632. } else if (isNumber(input)) {
  2633. // from milliseconds
  2634. config._d = new Date(input);
  2635. } else {
  2636. hooks.createFromInputFallback(config);
  2637. }
  2638. }
  2639. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  2640. var c = {};
  2641. if (format === true || format === false) {
  2642. strict = format;
  2643. format = undefined;
  2644. }
  2645. if (locale === true || locale === false) {
  2646. strict = locale;
  2647. locale = undefined;
  2648. }
  2649. if (
  2650. (isObject(input) && isObjectEmpty(input)) ||
  2651. (isArray(input) && input.length === 0)
  2652. ) {
  2653. input = undefined;
  2654. }
  2655. // object construction must be done this way.
  2656. // https://github.com/moment/moment/issues/1423
  2657. c._isAMomentObject = true;
  2658. c._useUTC = c._isUTC = isUTC;
  2659. c._l = locale;
  2660. c._i = input;
  2661. c._f = format;
  2662. c._strict = strict;
  2663. return createFromConfig(c);
  2664. }
  2665. function createLocal(input, format, locale, strict) {
  2666. return createLocalOrUTC(input, format, locale, strict, false);
  2667. }
  2668. var prototypeMin = deprecate(
  2669. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  2670. function () {
  2671. var other = createLocal.apply(null, arguments);
  2672. if (this.isValid() && other.isValid()) {
  2673. return other < this ? this : other;
  2674. } else {
  2675. return createInvalid();
  2676. }
  2677. }
  2678. ),
  2679. prototypeMax = deprecate(
  2680. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  2681. function () {
  2682. var other = createLocal.apply(null, arguments);
  2683. if (this.isValid() && other.isValid()) {
  2684. return other > this ? this : other;
  2685. } else {
  2686. return createInvalid();
  2687. }
  2688. }
  2689. );
  2690. // Pick a moment m from moments so that m[fn](other) is true for all
  2691. // other. This relies on the function fn to be transitive.
  2692. //
  2693. // moments should either be an array of moment objects or an array, whose
  2694. // first element is an array of moment objects.
  2695. function pickBy(fn, moments) {
  2696. var res, i;
  2697. if (moments.length === 1 && isArray(moments[0])) {
  2698. moments = moments[0];
  2699. }
  2700. if (!moments.length) {
  2701. return createLocal();
  2702. }
  2703. res = moments[0];
  2704. for (i = 1; i < moments.length; ++i) {
  2705. if (!moments[i].isValid() || moments[i][fn](res)) {
  2706. res = moments[i];
  2707. }
  2708. }
  2709. return res;
  2710. }
  2711. // TODO: Use [].sort instead?
  2712. function min() {
  2713. var args = [].slice.call(arguments, 0);
  2714. return pickBy('isBefore', args);
  2715. }
  2716. function max() {
  2717. var args = [].slice.call(arguments, 0);
  2718. return pickBy('isAfter', args);
  2719. }
  2720. var now = function () {
  2721. return Date.now ? Date.now() : +new Date();
  2722. };
  2723. var ordering = [
  2724. 'year',
  2725. 'quarter',
  2726. 'month',
  2727. 'week',
  2728. 'day',
  2729. 'hour',
  2730. 'minute',
  2731. 'second',
  2732. 'millisecond',
  2733. ];
  2734. function isDurationValid(m) {
  2735. var key,
  2736. unitHasDecimal = false,
  2737. i,
  2738. orderLen = ordering.length;
  2739. for (key in m) {
  2740. if (
  2741. hasOwnProp(m, key) &&
  2742. !(
  2743. indexOf.call(ordering, key) !== -1 &&
  2744. (m[key] == null || !isNaN(m[key]))
  2745. )
  2746. ) {
  2747. return false;
  2748. }
  2749. }
  2750. for (i = 0; i < orderLen; ++i) {
  2751. if (m[ordering[i]]) {
  2752. if (unitHasDecimal) {
  2753. return false; // only allow non-integers for smallest unit
  2754. }
  2755. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  2756. unitHasDecimal = true;
  2757. }
  2758. }
  2759. }
  2760. return true;
  2761. }
  2762. function isValid$1() {
  2763. return this._isValid;
  2764. }
  2765. function createInvalid$1() {
  2766. return createDuration(NaN);
  2767. }
  2768. function Duration(duration) {
  2769. var normalizedInput = normalizeObjectUnits(duration),
  2770. years = normalizedInput.year || 0,
  2771. quarters = normalizedInput.quarter || 0,
  2772. months = normalizedInput.month || 0,
  2773. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  2774. days = normalizedInput.day || 0,
  2775. hours = normalizedInput.hour || 0,
  2776. minutes = normalizedInput.minute || 0,
  2777. seconds = normalizedInput.second || 0,
  2778. milliseconds = normalizedInput.millisecond || 0;
  2779. this._isValid = isDurationValid(normalizedInput);
  2780. // representation for dateAddRemove
  2781. this._milliseconds =
  2782. +milliseconds +
  2783. seconds * 1e3 + // 1000
  2784. minutes * 6e4 + // 1000 * 60
  2785. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  2786. // Because of dateAddRemove treats 24 hours as different from a
  2787. // day when working around DST, we need to store them separately
  2788. this._days = +days + weeks * 7;
  2789. // It is impossible to translate months into days without knowing
  2790. // which months you are are talking about, so we have to store
  2791. // it separately.
  2792. this._months = +months + quarters * 3 + years * 12;
  2793. this._data = {};
  2794. this._locale = getLocale();
  2795. this._bubble();
  2796. }
  2797. function isDuration(obj) {
  2798. return obj instanceof Duration;
  2799. }
  2800. function absRound(number) {
  2801. if (number < 0) {
  2802. return Math.round(-1 * number) * -1;
  2803. } else {
  2804. return Math.round(number);
  2805. }
  2806. }
  2807. // compare two arrays, return the number of differences
  2808. function compareArrays(array1, array2, dontConvert) {
  2809. var len = Math.min(array1.length, array2.length),
  2810. lengthDiff = Math.abs(array1.length - array2.length),
  2811. diffs = 0,
  2812. i;
  2813. for (i = 0; i < len; i++) {
  2814. if (
  2815. (dontConvert && array1[i] !== array2[i]) ||
  2816. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  2817. ) {
  2818. diffs++;
  2819. }
  2820. }
  2821. return diffs + lengthDiff;
  2822. }
  2823. // FORMATTING
  2824. function offset(token, separator) {
  2825. addFormatToken(token, 0, 0, function () {
  2826. var offset = this.utcOffset(),
  2827. sign = '+';
  2828. if (offset < 0) {
  2829. offset = -offset;
  2830. sign = '-';
  2831. }
  2832. return (
  2833. sign +
  2834. zeroFill(~~(offset / 60), 2) +
  2835. separator +
  2836. zeroFill(~~offset % 60, 2)
  2837. );
  2838. });
  2839. }
  2840. offset('Z', ':');
  2841. offset('ZZ', '');
  2842. // PARSING
  2843. addRegexToken('Z', matchShortOffset);
  2844. addRegexToken('ZZ', matchShortOffset);
  2845. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  2846. config._useUTC = true;
  2847. config._tzm = offsetFromString(matchShortOffset, input);
  2848. });
  2849. // HELPERS
  2850. // timezone chunker
  2851. // '+10:00' > ['10', '00']
  2852. // '-1530' > ['-15', '30']
  2853. var chunkOffset = /([\+\-]|\d\d)/gi;
  2854. function offsetFromString(matcher, string) {
  2855. var matches = (string || '').match(matcher),
  2856. chunk,
  2857. parts,
  2858. minutes;
  2859. if (matches === null) {
  2860. return null;
  2861. }
  2862. chunk = matches[matches.length - 1] || [];
  2863. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  2864. minutes = +(parts[1] * 60) + toInt(parts[2]);
  2865. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  2866. }
  2867. // Return a moment from input, that is local/utc/zone equivalent to model.
  2868. function cloneWithOffset(input, model) {
  2869. var res, diff;
  2870. if (model._isUTC) {
  2871. res = model.clone();
  2872. diff =
  2873. (isMoment(input) || isDate(input)
  2874. ? input.valueOf()
  2875. : createLocal(input).valueOf()) - res.valueOf();
  2876. // Use low-level api, because this fn is low-level api.
  2877. res._d.setTime(res._d.valueOf() + diff);
  2878. hooks.updateOffset(res, false);
  2879. return res;
  2880. } else {
  2881. return createLocal(input).local();
  2882. }
  2883. }
  2884. function getDateOffset(m) {
  2885. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  2886. // https://github.com/moment/moment/pull/1871
  2887. return -Math.round(m._d.getTimezoneOffset());
  2888. }
  2889. // HOOKS
  2890. // This function will be called whenever a moment is mutated.
  2891. // It is intended to keep the offset in sync with the timezone.
  2892. hooks.updateOffset = function () {};
  2893. // MOMENTS
  2894. // keepLocalTime = true means only change the timezone, without
  2895. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  2896. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  2897. // +0200, so we adjust the time as needed, to be valid.
  2898. //
  2899. // Keeping the time actually adds/subtracts (one hour)
  2900. // from the actual represented time. That is why we call updateOffset
  2901. // a second time. In case it wants us to change the offset again
  2902. // _changeInProgress == true case, then we have to adjust, because
  2903. // there is no such time in the given timezone.
  2904. function getSetOffset(input, keepLocalTime, keepMinutes) {
  2905. var offset = this._offset || 0,
  2906. localAdjust;
  2907. if (!this.isValid()) {
  2908. return input != null ? this : NaN;
  2909. }
  2910. if (input != null) {
  2911. if (typeof input === 'string') {
  2912. input = offsetFromString(matchShortOffset, input);
  2913. if (input === null) {
  2914. return this;
  2915. }
  2916. } else if (Math.abs(input) < 16 && !keepMinutes) {
  2917. input = input * 60;
  2918. }
  2919. if (!this._isUTC && keepLocalTime) {
  2920. localAdjust = getDateOffset(this);
  2921. }
  2922. this._offset = input;
  2923. this._isUTC = true;
  2924. if (localAdjust != null) {
  2925. this.add(localAdjust, 'm');
  2926. }
  2927. if (offset !== input) {
  2928. if (!keepLocalTime || this._changeInProgress) {
  2929. addSubtract(
  2930. this,
  2931. createDuration(input - offset, 'm'),
  2932. 1,
  2933. false
  2934. );
  2935. } else if (!this._changeInProgress) {
  2936. this._changeInProgress = true;
  2937. hooks.updateOffset(this, true);
  2938. this._changeInProgress = null;
  2939. }
  2940. }
  2941. return this;
  2942. } else {
  2943. return this._isUTC ? offset : getDateOffset(this);
  2944. }
  2945. }
  2946. function getSetZone(input, keepLocalTime) {
  2947. if (input != null) {
  2948. if (typeof input !== 'string') {
  2949. input = -input;
  2950. }
  2951. this.utcOffset(input, keepLocalTime);
  2952. return this;
  2953. } else {
  2954. return -this.utcOffset();
  2955. }
  2956. }
  2957. function setOffsetToUTC(keepLocalTime) {
  2958. return this.utcOffset(0, keepLocalTime);
  2959. }
  2960. function setOffsetToLocal(keepLocalTime) {
  2961. if (this._isUTC) {
  2962. this.utcOffset(0, keepLocalTime);
  2963. this._isUTC = false;
  2964. if (keepLocalTime) {
  2965. this.subtract(getDateOffset(this), 'm');
  2966. }
  2967. }
  2968. return this;
  2969. }
  2970. function setOffsetToParsedOffset() {
  2971. if (this._tzm != null) {
  2972. this.utcOffset(this._tzm, false, true);
  2973. } else if (typeof this._i === 'string') {
  2974. var tZone = offsetFromString(matchOffset, this._i);
  2975. if (tZone != null) {
  2976. this.utcOffset(tZone);
  2977. } else {
  2978. this.utcOffset(0, true);
  2979. }
  2980. }
  2981. return this;
  2982. }
  2983. function hasAlignedHourOffset(input) {
  2984. if (!this.isValid()) {
  2985. return false;
  2986. }
  2987. input = input ? createLocal(input).utcOffset() : 0;
  2988. return (this.utcOffset() - input) % 60 === 0;
  2989. }
  2990. function isDaylightSavingTime() {
  2991. return (
  2992. this.utcOffset() > this.clone().month(0).utcOffset() ||
  2993. this.utcOffset() > this.clone().month(5).utcOffset()
  2994. );
  2995. }
  2996. function isDaylightSavingTimeShifted() {
  2997. if (!isUndefined(this._isDSTShifted)) {
  2998. return this._isDSTShifted;
  2999. }
  3000. var c = {},
  3001. other;
  3002. copyConfig(c, this);
  3003. c = prepareConfig(c);
  3004. if (c._a) {
  3005. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  3006. this._isDSTShifted =
  3007. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  3008. } else {
  3009. this._isDSTShifted = false;
  3010. }
  3011. return this._isDSTShifted;
  3012. }
  3013. function isLocal() {
  3014. return this.isValid() ? !this._isUTC : false;
  3015. }
  3016. function isUtcOffset() {
  3017. return this.isValid() ? this._isUTC : false;
  3018. }
  3019. function isUtc() {
  3020. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  3021. }
  3022. // ASP.NET json date format regex
  3023. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  3024. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  3025. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  3026. // and further modified to allow for strings containing both week and day
  3027. isoRegex =
  3028. /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  3029. function createDuration(input, key) {
  3030. var duration = input,
  3031. // matching against regexp is expensive, do it on demand
  3032. match = null,
  3033. sign,
  3034. ret,
  3035. diffRes;
  3036. if (isDuration(input)) {
  3037. duration = {
  3038. ms: input._milliseconds,
  3039. d: input._days,
  3040. M: input._months,
  3041. };
  3042. } else if (isNumber(input) || !isNaN(+input)) {
  3043. duration = {};
  3044. if (key) {
  3045. duration[key] = +input;
  3046. } else {
  3047. duration.milliseconds = +input;
  3048. }
  3049. } else if ((match = aspNetRegex.exec(input))) {
  3050. sign = match[1] === '-' ? -1 : 1;
  3051. duration = {
  3052. y: 0,
  3053. d: toInt(match[DATE]) * sign,
  3054. h: toInt(match[HOUR]) * sign,
  3055. m: toInt(match[MINUTE]) * sign,
  3056. s: toInt(match[SECOND]) * sign,
  3057. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  3058. };
  3059. } else if ((match = isoRegex.exec(input))) {
  3060. sign = match[1] === '-' ? -1 : 1;
  3061. duration = {
  3062. y: parseIso(match[2], sign),
  3063. M: parseIso(match[3], sign),
  3064. w: parseIso(match[4], sign),
  3065. d: parseIso(match[5], sign),
  3066. h: parseIso(match[6], sign),
  3067. m: parseIso(match[7], sign),
  3068. s: parseIso(match[8], sign),
  3069. };
  3070. } else if (duration == null) {
  3071. // checks for null or undefined
  3072. duration = {};
  3073. } else if (
  3074. typeof duration === 'object' &&
  3075. ('from' in duration || 'to' in duration)
  3076. ) {
  3077. diffRes = momentsDifference(
  3078. createLocal(duration.from),
  3079. createLocal(duration.to)
  3080. );
  3081. duration = {};
  3082. duration.ms = diffRes.milliseconds;
  3083. duration.M = diffRes.months;
  3084. }
  3085. ret = new Duration(duration);
  3086. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  3087. ret._locale = input._locale;
  3088. }
  3089. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  3090. ret._isValid = input._isValid;
  3091. }
  3092. return ret;
  3093. }
  3094. createDuration.fn = Duration.prototype;
  3095. createDuration.invalid = createInvalid$1;
  3096. function parseIso(inp, sign) {
  3097. // We'd normally use ~~inp for this, but unfortunately it also
  3098. // converts floats to ints.
  3099. // inp may be undefined, so careful calling replace on it.
  3100. var res = inp && parseFloat(inp.replace(',', '.'));
  3101. // apply sign while we're at it
  3102. return (isNaN(res) ? 0 : res) * sign;
  3103. }
  3104. function positiveMomentsDifference(base, other) {
  3105. var res = {};
  3106. res.months =
  3107. other.month() - base.month() + (other.year() - base.year()) * 12;
  3108. if (base.clone().add(res.months, 'M').isAfter(other)) {
  3109. --res.months;
  3110. }
  3111. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  3112. return res;
  3113. }
  3114. function momentsDifference(base, other) {
  3115. var res;
  3116. if (!(base.isValid() && other.isValid())) {
  3117. return { milliseconds: 0, months: 0 };
  3118. }
  3119. other = cloneWithOffset(other, base);
  3120. if (base.isBefore(other)) {
  3121. res = positiveMomentsDifference(base, other);
  3122. } else {
  3123. res = positiveMomentsDifference(other, base);
  3124. res.milliseconds = -res.milliseconds;
  3125. res.months = -res.months;
  3126. }
  3127. return res;
  3128. }
  3129. // TODO: remove 'name' arg after deprecation is removed
  3130. function createAdder(direction, name) {
  3131. return function (val, period) {
  3132. var dur, tmp;
  3133. //invert the arguments, but complain about it
  3134. if (period !== null && !isNaN(+period)) {
  3135. deprecateSimple(
  3136. name,
  3137. 'moment().' +
  3138. name +
  3139. '(period, number) is deprecated. Please use moment().' +
  3140. name +
  3141. '(number, period). ' +
  3142. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  3143. );
  3144. tmp = val;
  3145. val = period;
  3146. period = tmp;
  3147. }
  3148. dur = createDuration(val, period);
  3149. addSubtract(this, dur, direction);
  3150. return this;
  3151. };
  3152. }
  3153. function addSubtract(mom, duration, isAdding, updateOffset) {
  3154. var milliseconds = duration._milliseconds,
  3155. days = absRound(duration._days),
  3156. months = absRound(duration._months);
  3157. if (!mom.isValid()) {
  3158. // No op
  3159. return;
  3160. }
  3161. updateOffset = updateOffset == null ? true : updateOffset;
  3162. if (months) {
  3163. setMonth(mom, get(mom, 'Month') + months * isAdding);
  3164. }
  3165. if (days) {
  3166. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  3167. }
  3168. if (milliseconds) {
  3169. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  3170. }
  3171. if (updateOffset) {
  3172. hooks.updateOffset(mom, days || months);
  3173. }
  3174. }
  3175. var add = createAdder(1, 'add'),
  3176. subtract = createAdder(-1, 'subtract');
  3177. function isString(input) {
  3178. return typeof input === 'string' || input instanceof String;
  3179. }
  3180. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  3181. function isMomentInput(input) {
  3182. return (
  3183. isMoment(input) ||
  3184. isDate(input) ||
  3185. isString(input) ||
  3186. isNumber(input) ||
  3187. isNumberOrStringArray(input) ||
  3188. isMomentInputObject(input) ||
  3189. input === null ||
  3190. input === undefined
  3191. );
  3192. }
  3193. function isMomentInputObject(input) {
  3194. var objectTest = isObject(input) && !isObjectEmpty(input),
  3195. propertyTest = false,
  3196. properties = [
  3197. 'years',
  3198. 'year',
  3199. 'y',
  3200. 'months',
  3201. 'month',
  3202. 'M',
  3203. 'days',
  3204. 'day',
  3205. 'd',
  3206. 'dates',
  3207. 'date',
  3208. 'D',
  3209. 'hours',
  3210. 'hour',
  3211. 'h',
  3212. 'minutes',
  3213. 'minute',
  3214. 'm',
  3215. 'seconds',
  3216. 'second',
  3217. 's',
  3218. 'milliseconds',
  3219. 'millisecond',
  3220. 'ms',
  3221. ],
  3222. i,
  3223. property,
  3224. propertyLen = properties.length;
  3225. for (i = 0; i < propertyLen; i += 1) {
  3226. property = properties[i];
  3227. propertyTest = propertyTest || hasOwnProp(input, property);
  3228. }
  3229. return objectTest && propertyTest;
  3230. }
  3231. function isNumberOrStringArray(input) {
  3232. var arrayTest = isArray(input),
  3233. dataTypeTest = false;
  3234. if (arrayTest) {
  3235. dataTypeTest =
  3236. input.filter(function (item) {
  3237. return !isNumber(item) && isString(input);
  3238. }).length === 0;
  3239. }
  3240. return arrayTest && dataTypeTest;
  3241. }
  3242. function isCalendarSpec(input) {
  3243. var objectTest = isObject(input) && !isObjectEmpty(input),
  3244. propertyTest = false,
  3245. properties = [
  3246. 'sameDay',
  3247. 'nextDay',
  3248. 'lastDay',
  3249. 'nextWeek',
  3250. 'lastWeek',
  3251. 'sameElse',
  3252. ],
  3253. i,
  3254. property;
  3255. for (i = 0; i < properties.length; i += 1) {
  3256. property = properties[i];
  3257. propertyTest = propertyTest || hasOwnProp(input, property);
  3258. }
  3259. return objectTest && propertyTest;
  3260. }
  3261. function getCalendarFormat(myMoment, now) {
  3262. var diff = myMoment.diff(now, 'days', true);
  3263. return diff < -6
  3264. ? 'sameElse'
  3265. : diff < -1
  3266. ? 'lastWeek'
  3267. : diff < 0
  3268. ? 'lastDay'
  3269. : diff < 1
  3270. ? 'sameDay'
  3271. : diff < 2
  3272. ? 'nextDay'
  3273. : diff < 7
  3274. ? 'nextWeek'
  3275. : 'sameElse';
  3276. }
  3277. function calendar$1(time, formats) {
  3278. // Support for single parameter, formats only overload to the calendar function
  3279. if (arguments.length === 1) {
  3280. if (!arguments[0]) {
  3281. time = undefined;
  3282. formats = undefined;
  3283. } else if (isMomentInput(arguments[0])) {
  3284. time = arguments[0];
  3285. formats = undefined;
  3286. } else if (isCalendarSpec(arguments[0])) {
  3287. formats = arguments[0];
  3288. time = undefined;
  3289. }
  3290. }
  3291. // We want to compare the start of today, vs this.
  3292. // Getting start-of-today depends on whether we're local/utc/offset or not.
  3293. var now = time || createLocal(),
  3294. sod = cloneWithOffset(now, this).startOf('day'),
  3295. format = hooks.calendarFormat(this, sod) || 'sameElse',
  3296. output =
  3297. formats &&
  3298. (isFunction(formats[format])
  3299. ? formats[format].call(this, now)
  3300. : formats[format]);
  3301. return this.format(
  3302. output || this.localeData().calendar(format, this, createLocal(now))
  3303. );
  3304. }
  3305. function clone() {
  3306. return new Moment(this);
  3307. }
  3308. function isAfter(input, units) {
  3309. var localInput = isMoment(input) ? input : createLocal(input);
  3310. if (!(this.isValid() && localInput.isValid())) {
  3311. return false;
  3312. }
  3313. units = normalizeUnits(units) || 'millisecond';
  3314. if (units === 'millisecond') {
  3315. return this.valueOf() > localInput.valueOf();
  3316. } else {
  3317. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  3318. }
  3319. }
  3320. function isBefore(input, units) {
  3321. var localInput = isMoment(input) ? input : createLocal(input);
  3322. if (!(this.isValid() && localInput.isValid())) {
  3323. return false;
  3324. }
  3325. units = normalizeUnits(units) || 'millisecond';
  3326. if (units === 'millisecond') {
  3327. return this.valueOf() < localInput.valueOf();
  3328. } else {
  3329. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  3330. }
  3331. }
  3332. function isBetween(from, to, units, inclusivity) {
  3333. var localFrom = isMoment(from) ? from : createLocal(from),
  3334. localTo = isMoment(to) ? to : createLocal(to);
  3335. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  3336. return false;
  3337. }
  3338. inclusivity = inclusivity || '()';
  3339. return (
  3340. (inclusivity[0] === '('
  3341. ? this.isAfter(localFrom, units)
  3342. : !this.isBefore(localFrom, units)) &&
  3343. (inclusivity[1] === ')'
  3344. ? this.isBefore(localTo, units)
  3345. : !this.isAfter(localTo, units))
  3346. );
  3347. }
  3348. function isSame(input, units) {
  3349. var localInput = isMoment(input) ? input : createLocal(input),
  3350. inputMs;
  3351. if (!(this.isValid() && localInput.isValid())) {
  3352. return false;
  3353. }
  3354. units = normalizeUnits(units) || 'millisecond';
  3355. if (units === 'millisecond') {
  3356. return this.valueOf() === localInput.valueOf();
  3357. } else {
  3358. inputMs = localInput.valueOf();
  3359. return (
  3360. this.clone().startOf(units).valueOf() <= inputMs &&
  3361. inputMs <= this.clone().endOf(units).valueOf()
  3362. );
  3363. }
  3364. }
  3365. function isSameOrAfter(input, units) {
  3366. return this.isSame(input, units) || this.isAfter(input, units);
  3367. }
  3368. function isSameOrBefore(input, units) {
  3369. return this.isSame(input, units) || this.isBefore(input, units);
  3370. }
  3371. function diff(input, units, asFloat) {
  3372. var that, zoneDelta, output;
  3373. if (!this.isValid()) {
  3374. return NaN;
  3375. }
  3376. that = cloneWithOffset(input, this);
  3377. if (!that.isValid()) {
  3378. return NaN;
  3379. }
  3380. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  3381. units = normalizeUnits(units);
  3382. switch (units) {
  3383. case 'year':
  3384. output = monthDiff(this, that) / 12;
  3385. break;
  3386. case 'month':
  3387. output = monthDiff(this, that);
  3388. break;
  3389. case 'quarter':
  3390. output = monthDiff(this, that) / 3;
  3391. break;
  3392. case 'second':
  3393. output = (this - that) / 1e3;
  3394. break; // 1000
  3395. case 'minute':
  3396. output = (this - that) / 6e4;
  3397. break; // 1000 * 60
  3398. case 'hour':
  3399. output = (this - that) / 36e5;
  3400. break; // 1000 * 60 * 60
  3401. case 'day':
  3402. output = (this - that - zoneDelta) / 864e5;
  3403. break; // 1000 * 60 * 60 * 24, negate dst
  3404. case 'week':
  3405. output = (this - that - zoneDelta) / 6048e5;
  3406. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  3407. default:
  3408. output = this - that;
  3409. }
  3410. return asFloat ? output : absFloor(output);
  3411. }
  3412. function monthDiff(a, b) {
  3413. if (a.date() < b.date()) {
  3414. // end-of-month calculations work correct when the start month has more
  3415. // days than the end month.
  3416. return -monthDiff(b, a);
  3417. }
  3418. // difference in months
  3419. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  3420. // b is in (anchor - 1 month, anchor + 1 month)
  3421. anchor = a.clone().add(wholeMonthDiff, 'months'),
  3422. anchor2,
  3423. adjust;
  3424. if (b - anchor < 0) {
  3425. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  3426. // linear across the month
  3427. adjust = (b - anchor) / (anchor - anchor2);
  3428. } else {
  3429. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  3430. // linear across the month
  3431. adjust = (b - anchor) / (anchor2 - anchor);
  3432. }
  3433. //check for negative zero, return zero if negative zero
  3434. return -(wholeMonthDiff + adjust) || 0;
  3435. }
  3436. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  3437. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  3438. function toString() {
  3439. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  3440. }
  3441. function toISOString(keepOffset) {
  3442. if (!this.isValid()) {
  3443. return null;
  3444. }
  3445. var utc = keepOffset !== true,
  3446. m = utc ? this.clone().utc() : this;
  3447. if (m.year() < 0 || m.year() > 9999) {
  3448. return formatMoment(
  3449. m,
  3450. utc
  3451. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  3452. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  3453. );
  3454. }
  3455. if (isFunction(Date.prototype.toISOString)) {
  3456. // native implementation is ~50x faster, use it when we can
  3457. if (utc) {
  3458. return this.toDate().toISOString();
  3459. } else {
  3460. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  3461. .toISOString()
  3462. .replace('Z', formatMoment(m, 'Z'));
  3463. }
  3464. }
  3465. return formatMoment(
  3466. m,
  3467. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  3468. );
  3469. }
  3470. /**
  3471. * Return a human readable representation of a moment that can
  3472. * also be evaluated to get a new moment which is the same
  3473. *
  3474. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  3475. */
  3476. function inspect() {
  3477. if (!this.isValid()) {
  3478. return 'moment.invalid(/* ' + this._i + ' */)';
  3479. }
  3480. var func = 'moment',
  3481. zone = '',
  3482. prefix,
  3483. year,
  3484. datetime,
  3485. suffix;
  3486. if (!this.isLocal()) {
  3487. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  3488. zone = 'Z';
  3489. }
  3490. prefix = '[' + func + '("]';
  3491. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  3492. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  3493. suffix = zone + '[")]';
  3494. return this.format(prefix + year + datetime + suffix);
  3495. }
  3496. function format(inputString) {
  3497. if (!inputString) {
  3498. inputString = this.isUtc()
  3499. ? hooks.defaultFormatUtc
  3500. : hooks.defaultFormat;
  3501. }
  3502. var output = formatMoment(this, inputString);
  3503. return this.localeData().postformat(output);
  3504. }
  3505. function from(time, withoutSuffix) {
  3506. if (
  3507. this.isValid() &&
  3508. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  3509. ) {
  3510. return createDuration({ to: this, from: time })
  3511. .locale(this.locale())
  3512. .humanize(!withoutSuffix);
  3513. } else {
  3514. return this.localeData().invalidDate();
  3515. }
  3516. }
  3517. function fromNow(withoutSuffix) {
  3518. return this.from(createLocal(), withoutSuffix);
  3519. }
  3520. function to(time, withoutSuffix) {
  3521. if (
  3522. this.isValid() &&
  3523. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  3524. ) {
  3525. return createDuration({ from: this, to: time })
  3526. .locale(this.locale())
  3527. .humanize(!withoutSuffix);
  3528. } else {
  3529. return this.localeData().invalidDate();
  3530. }
  3531. }
  3532. function toNow(withoutSuffix) {
  3533. return this.to(createLocal(), withoutSuffix);
  3534. }
  3535. // If passed a locale key, it will set the locale for this
  3536. // instance. Otherwise, it will return the locale configuration
  3537. // variables for this instance.
  3538. function locale(key) {
  3539. var newLocaleData;
  3540. if (key === undefined) {
  3541. return this._locale._abbr;
  3542. } else {
  3543. newLocaleData = getLocale(key);
  3544. if (newLocaleData != null) {
  3545. this._locale = newLocaleData;
  3546. }
  3547. return this;
  3548. }
  3549. }
  3550. var lang = deprecate(
  3551. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  3552. function (key) {
  3553. if (key === undefined) {
  3554. return this.localeData();
  3555. } else {
  3556. return this.locale(key);
  3557. }
  3558. }
  3559. );
  3560. function localeData() {
  3561. return this._locale;
  3562. }
  3563. var MS_PER_SECOND = 1000,
  3564. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  3565. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  3566. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  3567. // actual modulo - handles negative numbers (for dates before 1970):
  3568. function mod$1(dividend, divisor) {
  3569. return ((dividend % divisor) + divisor) % divisor;
  3570. }
  3571. function localStartOfDate(y, m, d) {
  3572. // the date constructor remaps years 0-99 to 1900-1999
  3573. if (y < 100 && y >= 0) {
  3574. // preserve leap years using a full 400 year cycle, then reset
  3575. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  3576. } else {
  3577. return new Date(y, m, d).valueOf();
  3578. }
  3579. }
  3580. function utcStartOfDate(y, m, d) {
  3581. // Date.UTC remaps years 0-99 to 1900-1999
  3582. if (y < 100 && y >= 0) {
  3583. // preserve leap years using a full 400 year cycle, then reset
  3584. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  3585. } else {
  3586. return Date.UTC(y, m, d);
  3587. }
  3588. }
  3589. function startOf(units) {
  3590. var time, startOfDate;
  3591. units = normalizeUnits(units);
  3592. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  3593. return this;
  3594. }
  3595. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  3596. switch (units) {
  3597. case 'year':
  3598. time = startOfDate(this.year(), 0, 1);
  3599. break;
  3600. case 'quarter':
  3601. time = startOfDate(
  3602. this.year(),
  3603. this.month() - (this.month() % 3),
  3604. 1
  3605. );
  3606. break;
  3607. case 'month':
  3608. time = startOfDate(this.year(), this.month(), 1);
  3609. break;
  3610. case 'week':
  3611. time = startOfDate(
  3612. this.year(),
  3613. this.month(),
  3614. this.date() - this.weekday()
  3615. );
  3616. break;
  3617. case 'isoWeek':
  3618. time = startOfDate(
  3619. this.year(),
  3620. this.month(),
  3621. this.date() - (this.isoWeekday() - 1)
  3622. );
  3623. break;
  3624. case 'day':
  3625. case 'date':
  3626. time = startOfDate(this.year(), this.month(), this.date());
  3627. break;
  3628. case 'hour':
  3629. time = this._d.valueOf();
  3630. time -= mod$1(
  3631. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  3632. MS_PER_HOUR
  3633. );
  3634. break;
  3635. case 'minute':
  3636. time = this._d.valueOf();
  3637. time -= mod$1(time, MS_PER_MINUTE);
  3638. break;
  3639. case 'second':
  3640. time = this._d.valueOf();
  3641. time -= mod$1(time, MS_PER_SECOND);
  3642. break;
  3643. }
  3644. this._d.setTime(time);
  3645. hooks.updateOffset(this, true);
  3646. return this;
  3647. }
  3648. function endOf(units) {
  3649. var time, startOfDate;
  3650. units = normalizeUnits(units);
  3651. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  3652. return this;
  3653. }
  3654. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  3655. switch (units) {
  3656. case 'year':
  3657. time = startOfDate(this.year() + 1, 0, 1) - 1;
  3658. break;
  3659. case 'quarter':
  3660. time =
  3661. startOfDate(
  3662. this.year(),
  3663. this.month() - (this.month() % 3) + 3,
  3664. 1
  3665. ) - 1;
  3666. break;
  3667. case 'month':
  3668. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  3669. break;
  3670. case 'week':
  3671. time =
  3672. startOfDate(
  3673. this.year(),
  3674. this.month(),
  3675. this.date() - this.weekday() + 7
  3676. ) - 1;
  3677. break;
  3678. case 'isoWeek':
  3679. time =
  3680. startOfDate(
  3681. this.year(),
  3682. this.month(),
  3683. this.date() - (this.isoWeekday() - 1) + 7
  3684. ) - 1;
  3685. break;
  3686. case 'day':
  3687. case 'date':
  3688. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  3689. break;
  3690. case 'hour':
  3691. time = this._d.valueOf();
  3692. time +=
  3693. MS_PER_HOUR -
  3694. mod$1(
  3695. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  3696. MS_PER_HOUR
  3697. ) -
  3698. 1;
  3699. break;
  3700. case 'minute':
  3701. time = this._d.valueOf();
  3702. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  3703. break;
  3704. case 'second':
  3705. time = this._d.valueOf();
  3706. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  3707. break;
  3708. }
  3709. this._d.setTime(time);
  3710. hooks.updateOffset(this, true);
  3711. return this;
  3712. }
  3713. function valueOf() {
  3714. return this._d.valueOf() - (this._offset || 0) * 60000;
  3715. }
  3716. function unix() {
  3717. return Math.floor(this.valueOf() / 1000);
  3718. }
  3719. function toDate() {
  3720. return new Date(this.valueOf());
  3721. }
  3722. function toArray() {
  3723. var m = this;
  3724. return [
  3725. m.year(),
  3726. m.month(),
  3727. m.date(),
  3728. m.hour(),
  3729. m.minute(),
  3730. m.second(),
  3731. m.millisecond(),
  3732. ];
  3733. }
  3734. function toObject() {
  3735. var m = this;
  3736. return {
  3737. years: m.year(),
  3738. months: m.month(),
  3739. date: m.date(),
  3740. hours: m.hours(),
  3741. minutes: m.minutes(),
  3742. seconds: m.seconds(),
  3743. milliseconds: m.milliseconds(),
  3744. };
  3745. }
  3746. function toJSON() {
  3747. // new Date(NaN).toJSON() === null
  3748. return this.isValid() ? this.toISOString() : null;
  3749. }
  3750. function isValid$2() {
  3751. return isValid(this);
  3752. }
  3753. function parsingFlags() {
  3754. return extend({}, getParsingFlags(this));
  3755. }
  3756. function invalidAt() {
  3757. return getParsingFlags(this).overflow;
  3758. }
  3759. function creationData() {
  3760. return {
  3761. input: this._i,
  3762. format: this._f,
  3763. locale: this._locale,
  3764. isUTC: this._isUTC,
  3765. strict: this._strict,
  3766. };
  3767. }
  3768. addFormatToken('N', 0, 0, 'eraAbbr');
  3769. addFormatToken('NN', 0, 0, 'eraAbbr');
  3770. addFormatToken('NNN', 0, 0, 'eraAbbr');
  3771. addFormatToken('NNNN', 0, 0, 'eraName');
  3772. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  3773. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  3774. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  3775. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  3776. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  3777. addRegexToken('N', matchEraAbbr);
  3778. addRegexToken('NN', matchEraAbbr);
  3779. addRegexToken('NNN', matchEraAbbr);
  3780. addRegexToken('NNNN', matchEraName);
  3781. addRegexToken('NNNNN', matchEraNarrow);
  3782. addParseToken(
  3783. ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'],
  3784. function (input, array, config, token) {
  3785. var era = config._locale.erasParse(input, token, config._strict);
  3786. if (era) {
  3787. getParsingFlags(config).era = era;
  3788. } else {
  3789. getParsingFlags(config).invalidEra = input;
  3790. }
  3791. }
  3792. );
  3793. addRegexToken('y', matchUnsigned);
  3794. addRegexToken('yy', matchUnsigned);
  3795. addRegexToken('yyy', matchUnsigned);
  3796. addRegexToken('yyyy', matchUnsigned);
  3797. addRegexToken('yo', matchEraYearOrdinal);
  3798. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  3799. addParseToken(['yo'], function (input, array, config, token) {
  3800. var match;
  3801. if (config._locale._eraYearOrdinalRegex) {
  3802. match = input.match(config._locale._eraYearOrdinalRegex);
  3803. }
  3804. if (config._locale.eraYearOrdinalParse) {
  3805. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  3806. } else {
  3807. array[YEAR] = parseInt(input, 10);
  3808. }
  3809. });
  3810. function localeEras(m, format) {
  3811. var i,
  3812. l,
  3813. date,
  3814. eras = this._eras || getLocale('en')._eras;
  3815. for (i = 0, l = eras.length; i < l; ++i) {
  3816. switch (typeof eras[i].since) {
  3817. case 'string':
  3818. // truncate time
  3819. date = hooks(eras[i].since).startOf('day');
  3820. eras[i].since = date.valueOf();
  3821. break;
  3822. }
  3823. switch (typeof eras[i].until) {
  3824. case 'undefined':
  3825. eras[i].until = +Infinity;
  3826. break;
  3827. case 'string':
  3828. // truncate time
  3829. date = hooks(eras[i].until).startOf('day').valueOf();
  3830. eras[i].until = date.valueOf();
  3831. break;
  3832. }
  3833. }
  3834. return eras;
  3835. }
  3836. function localeErasParse(eraName, format, strict) {
  3837. var i,
  3838. l,
  3839. eras = this.eras(),
  3840. name,
  3841. abbr,
  3842. narrow;
  3843. eraName = eraName.toUpperCase();
  3844. for (i = 0, l = eras.length; i < l; ++i) {
  3845. name = eras[i].name.toUpperCase();
  3846. abbr = eras[i].abbr.toUpperCase();
  3847. narrow = eras[i].narrow.toUpperCase();
  3848. if (strict) {
  3849. switch (format) {
  3850. case 'N':
  3851. case 'NN':
  3852. case 'NNN':
  3853. if (abbr === eraName) {
  3854. return eras[i];
  3855. }
  3856. break;
  3857. case 'NNNN':
  3858. if (name === eraName) {
  3859. return eras[i];
  3860. }
  3861. break;
  3862. case 'NNNNN':
  3863. if (narrow === eraName) {
  3864. return eras[i];
  3865. }
  3866. break;
  3867. }
  3868. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  3869. return eras[i];
  3870. }
  3871. }
  3872. }
  3873. function localeErasConvertYear(era, year) {
  3874. var dir = era.since <= era.until ? +1 : -1;
  3875. if (year === undefined) {
  3876. return hooks(era.since).year();
  3877. } else {
  3878. return hooks(era.since).year() + (year - era.offset) * dir;
  3879. }
  3880. }
  3881. function getEraName() {
  3882. var i,
  3883. l,
  3884. val,
  3885. eras = this.localeData().eras();
  3886. for (i = 0, l = eras.length; i < l; ++i) {
  3887. // truncate time
  3888. val = this.clone().startOf('day').valueOf();
  3889. if (eras[i].since <= val && val <= eras[i].until) {
  3890. return eras[i].name;
  3891. }
  3892. if (eras[i].until <= val && val <= eras[i].since) {
  3893. return eras[i].name;
  3894. }
  3895. }
  3896. return '';
  3897. }
  3898. function getEraNarrow() {
  3899. var i,
  3900. l,
  3901. val,
  3902. eras = this.localeData().eras();
  3903. for (i = 0, l = eras.length; i < l; ++i) {
  3904. // truncate time
  3905. val = this.clone().startOf('day').valueOf();
  3906. if (eras[i].since <= val && val <= eras[i].until) {
  3907. return eras[i].narrow;
  3908. }
  3909. if (eras[i].until <= val && val <= eras[i].since) {
  3910. return eras[i].narrow;
  3911. }
  3912. }
  3913. return '';
  3914. }
  3915. function getEraAbbr() {
  3916. var i,
  3917. l,
  3918. val,
  3919. eras = this.localeData().eras();
  3920. for (i = 0, l = eras.length; i < l; ++i) {
  3921. // truncate time
  3922. val = this.clone().startOf('day').valueOf();
  3923. if (eras[i].since <= val && val <= eras[i].until) {
  3924. return eras[i].abbr;
  3925. }
  3926. if (eras[i].until <= val && val <= eras[i].since) {
  3927. return eras[i].abbr;
  3928. }
  3929. }
  3930. return '';
  3931. }
  3932. function getEraYear() {
  3933. var i,
  3934. l,
  3935. dir,
  3936. val,
  3937. eras = this.localeData().eras();
  3938. for (i = 0, l = eras.length; i < l; ++i) {
  3939. dir = eras[i].since <= eras[i].until ? +1 : -1;
  3940. // truncate time
  3941. val = this.clone().startOf('day').valueOf();
  3942. if (
  3943. (eras[i].since <= val && val <= eras[i].until) ||
  3944. (eras[i].until <= val && val <= eras[i].since)
  3945. ) {
  3946. return (
  3947. (this.year() - hooks(eras[i].since).year()) * dir +
  3948. eras[i].offset
  3949. );
  3950. }
  3951. }
  3952. return this.year();
  3953. }
  3954. function erasNameRegex(isStrict) {
  3955. if (!hasOwnProp(this, '_erasNameRegex')) {
  3956. computeErasParse.call(this);
  3957. }
  3958. return isStrict ? this._erasNameRegex : this._erasRegex;
  3959. }
  3960. function erasAbbrRegex(isStrict) {
  3961. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  3962. computeErasParse.call(this);
  3963. }
  3964. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  3965. }
  3966. function erasNarrowRegex(isStrict) {
  3967. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  3968. computeErasParse.call(this);
  3969. }
  3970. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  3971. }
  3972. function matchEraAbbr(isStrict, locale) {
  3973. return locale.erasAbbrRegex(isStrict);
  3974. }
  3975. function matchEraName(isStrict, locale) {
  3976. return locale.erasNameRegex(isStrict);
  3977. }
  3978. function matchEraNarrow(isStrict, locale) {
  3979. return locale.erasNarrowRegex(isStrict);
  3980. }
  3981. function matchEraYearOrdinal(isStrict, locale) {
  3982. return locale._eraYearOrdinalRegex || matchUnsigned;
  3983. }
  3984. function computeErasParse() {
  3985. var abbrPieces = [],
  3986. namePieces = [],
  3987. narrowPieces = [],
  3988. mixedPieces = [],
  3989. i,
  3990. l,
  3991. eras = this.eras();
  3992. for (i = 0, l = eras.length; i < l; ++i) {
  3993. namePieces.push(regexEscape(eras[i].name));
  3994. abbrPieces.push(regexEscape(eras[i].abbr));
  3995. narrowPieces.push(regexEscape(eras[i].narrow));
  3996. mixedPieces.push(regexEscape(eras[i].name));
  3997. mixedPieces.push(regexEscape(eras[i].abbr));
  3998. mixedPieces.push(regexEscape(eras[i].narrow));
  3999. }
  4000. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  4001. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  4002. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  4003. this._erasNarrowRegex = new RegExp(
  4004. '^(' + narrowPieces.join('|') + ')',
  4005. 'i'
  4006. );
  4007. }
  4008. // FORMATTING
  4009. addFormatToken(0, ['gg', 2], 0, function () {
  4010. return this.weekYear() % 100;
  4011. });
  4012. addFormatToken(0, ['GG', 2], 0, function () {
  4013. return this.isoWeekYear() % 100;
  4014. });
  4015. function addWeekYearFormatToken(token, getter) {
  4016. addFormatToken(0, [token, token.length], 0, getter);
  4017. }
  4018. addWeekYearFormatToken('gggg', 'weekYear');
  4019. addWeekYearFormatToken('ggggg', 'weekYear');
  4020. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  4021. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  4022. // ALIASES
  4023. addUnitAlias('weekYear', 'gg');
  4024. addUnitAlias('isoWeekYear', 'GG');
  4025. // PRIORITY
  4026. addUnitPriority('weekYear', 1);
  4027. addUnitPriority('isoWeekYear', 1);
  4028. // PARSING
  4029. addRegexToken('G', matchSigned);
  4030. addRegexToken('g', matchSigned);
  4031. addRegexToken('GG', match1to2, match2);
  4032. addRegexToken('gg', match1to2, match2);
  4033. addRegexToken('GGGG', match1to4, match4);
  4034. addRegexToken('gggg', match1to4, match4);
  4035. addRegexToken('GGGGG', match1to6, match6);
  4036. addRegexToken('ggggg', match1to6, match6);
  4037. addWeekParseToken(
  4038. ['gggg', 'ggggg', 'GGGG', 'GGGGG'],
  4039. function (input, week, config, token) {
  4040. week[token.substr(0, 2)] = toInt(input);
  4041. }
  4042. );
  4043. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  4044. week[token] = hooks.parseTwoDigitYear(input);
  4045. });
  4046. // MOMENTS
  4047. function getSetWeekYear(input) {
  4048. return getSetWeekYearHelper.call(
  4049. this,
  4050. input,
  4051. this.week(),
  4052. this.weekday(),
  4053. this.localeData()._week.dow,
  4054. this.localeData()._week.doy
  4055. );
  4056. }
  4057. function getSetISOWeekYear(input) {
  4058. return getSetWeekYearHelper.call(
  4059. this,
  4060. input,
  4061. this.isoWeek(),
  4062. this.isoWeekday(),
  4063. 1,
  4064. 4
  4065. );
  4066. }
  4067. function getISOWeeksInYear() {
  4068. return weeksInYear(this.year(), 1, 4);
  4069. }
  4070. function getISOWeeksInISOWeekYear() {
  4071. return weeksInYear(this.isoWeekYear(), 1, 4);
  4072. }
  4073. function getWeeksInYear() {
  4074. var weekInfo = this.localeData()._week;
  4075. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  4076. }
  4077. function getWeeksInWeekYear() {
  4078. var weekInfo = this.localeData()._week;
  4079. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  4080. }
  4081. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  4082. var weeksTarget;
  4083. if (input == null) {
  4084. return weekOfYear(this, dow, doy).year;
  4085. } else {
  4086. weeksTarget = weeksInYear(input, dow, doy);
  4087. if (week > weeksTarget) {
  4088. week = weeksTarget;
  4089. }
  4090. return setWeekAll.call(this, input, week, weekday, dow, doy);
  4091. }
  4092. }
  4093. function setWeekAll(weekYear, week, weekday, dow, doy) {
  4094. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  4095. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  4096. this.year(date.getUTCFullYear());
  4097. this.month(date.getUTCMonth());
  4098. this.date(date.getUTCDate());
  4099. return this;
  4100. }
  4101. // FORMATTING
  4102. addFormatToken('Q', 0, 'Qo', 'quarter');
  4103. // ALIASES
  4104. addUnitAlias('quarter', 'Q');
  4105. // PRIORITY
  4106. addUnitPriority('quarter', 7);
  4107. // PARSING
  4108. addRegexToken('Q', match1);
  4109. addParseToken('Q', function (input, array) {
  4110. array[MONTH] = (toInt(input) - 1) * 3;
  4111. });
  4112. // MOMENTS
  4113. function getSetQuarter(input) {
  4114. return input == null
  4115. ? Math.ceil((this.month() + 1) / 3)
  4116. : this.month((input - 1) * 3 + (this.month() % 3));
  4117. }
  4118. // FORMATTING
  4119. addFormatToken('D', ['DD', 2], 'Do', 'date');
  4120. // ALIASES
  4121. addUnitAlias('date', 'D');
  4122. // PRIORITY
  4123. addUnitPriority('date', 9);
  4124. // PARSING
  4125. addRegexToken('D', match1to2);
  4126. addRegexToken('DD', match1to2, match2);
  4127. addRegexToken('Do', function (isStrict, locale) {
  4128. // TODO: Remove "ordinalParse" fallback in next major release.
  4129. return isStrict
  4130. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  4131. : locale._dayOfMonthOrdinalParseLenient;
  4132. });
  4133. addParseToken(['D', 'DD'], DATE);
  4134. addParseToken('Do', function (input, array) {
  4135. array[DATE] = toInt(input.match(match1to2)[0]);
  4136. });
  4137. // MOMENTS
  4138. var getSetDayOfMonth = makeGetSet('Date', true);
  4139. // FORMATTING
  4140. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  4141. // ALIASES
  4142. addUnitAlias('dayOfYear', 'DDD');
  4143. // PRIORITY
  4144. addUnitPriority('dayOfYear', 4);
  4145. // PARSING
  4146. addRegexToken('DDD', match1to3);
  4147. addRegexToken('DDDD', match3);
  4148. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  4149. config._dayOfYear = toInt(input);
  4150. });
  4151. // HELPERS
  4152. // MOMENTS
  4153. function getSetDayOfYear(input) {
  4154. var dayOfYear =
  4155. Math.round(
  4156. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  4157. ) + 1;
  4158. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  4159. }
  4160. // FORMATTING
  4161. addFormatToken('m', ['mm', 2], 0, 'minute');
  4162. // ALIASES
  4163. addUnitAlias('minute', 'm');
  4164. // PRIORITY
  4165. addUnitPriority('minute', 14);
  4166. // PARSING
  4167. addRegexToken('m', match1to2);
  4168. addRegexToken('mm', match1to2, match2);
  4169. addParseToken(['m', 'mm'], MINUTE);
  4170. // MOMENTS
  4171. var getSetMinute = makeGetSet('Minutes', false);
  4172. // FORMATTING
  4173. addFormatToken('s', ['ss', 2], 0, 'second');
  4174. // ALIASES
  4175. addUnitAlias('second', 's');
  4176. // PRIORITY
  4177. addUnitPriority('second', 15);
  4178. // PARSING
  4179. addRegexToken('s', match1to2);
  4180. addRegexToken('ss', match1to2, match2);
  4181. addParseToken(['s', 'ss'], SECOND);
  4182. // MOMENTS
  4183. var getSetSecond = makeGetSet('Seconds', false);
  4184. // FORMATTING
  4185. addFormatToken('S', 0, 0, function () {
  4186. return ~~(this.millisecond() / 100);
  4187. });
  4188. addFormatToken(0, ['SS', 2], 0, function () {
  4189. return ~~(this.millisecond() / 10);
  4190. });
  4191. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  4192. addFormatToken(0, ['SSSS', 4], 0, function () {
  4193. return this.millisecond() * 10;
  4194. });
  4195. addFormatToken(0, ['SSSSS', 5], 0, function () {
  4196. return this.millisecond() * 100;
  4197. });
  4198. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  4199. return this.millisecond() * 1000;
  4200. });
  4201. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  4202. return this.millisecond() * 10000;
  4203. });
  4204. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  4205. return this.millisecond() * 100000;
  4206. });
  4207. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  4208. return this.millisecond() * 1000000;
  4209. });
  4210. // ALIASES
  4211. addUnitAlias('millisecond', 'ms');
  4212. // PRIORITY
  4213. addUnitPriority('millisecond', 16);
  4214. // PARSING
  4215. addRegexToken('S', match1to3, match1);
  4216. addRegexToken('SS', match1to3, match2);
  4217. addRegexToken('SSS', match1to3, match3);
  4218. var token, getSetMillisecond;
  4219. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  4220. addRegexToken(token, matchUnsigned);
  4221. }
  4222. function parseMs(input, array) {
  4223. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  4224. }
  4225. for (token = 'S'; token.length <= 9; token += 'S') {
  4226. addParseToken(token, parseMs);
  4227. }
  4228. getSetMillisecond = makeGetSet('Milliseconds', false);
  4229. // FORMATTING
  4230. addFormatToken('z', 0, 0, 'zoneAbbr');
  4231. addFormatToken('zz', 0, 0, 'zoneName');
  4232. // MOMENTS
  4233. function getZoneAbbr() {
  4234. return this._isUTC ? 'UTC' : '';
  4235. }
  4236. function getZoneName() {
  4237. return this._isUTC ? 'Coordinated Universal Time' : '';
  4238. }
  4239. var proto = Moment.prototype;
  4240. proto.add = add;
  4241. proto.calendar = calendar$1;
  4242. proto.clone = clone;
  4243. proto.diff = diff;
  4244. proto.endOf = endOf;
  4245. proto.format = format;
  4246. proto.from = from;
  4247. proto.fromNow = fromNow;
  4248. proto.to = to;
  4249. proto.toNow = toNow;
  4250. proto.get = stringGet;
  4251. proto.invalidAt = invalidAt;
  4252. proto.isAfter = isAfter;
  4253. proto.isBefore = isBefore;
  4254. proto.isBetween = isBetween;
  4255. proto.isSame = isSame;
  4256. proto.isSameOrAfter = isSameOrAfter;
  4257. proto.isSameOrBefore = isSameOrBefore;
  4258. proto.isValid = isValid$2;
  4259. proto.lang = lang;
  4260. proto.locale = locale;
  4261. proto.localeData = localeData;
  4262. proto.max = prototypeMax;
  4263. proto.min = prototypeMin;
  4264. proto.parsingFlags = parsingFlags;
  4265. proto.set = stringSet;
  4266. proto.startOf = startOf;
  4267. proto.subtract = subtract;
  4268. proto.toArray = toArray;
  4269. proto.toObject = toObject;
  4270. proto.toDate = toDate;
  4271. proto.toISOString = toISOString;
  4272. proto.inspect = inspect;
  4273. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  4274. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  4275. return 'Moment<' + this.format() + '>';
  4276. };
  4277. }
  4278. proto.toJSON = toJSON;
  4279. proto.toString = toString;
  4280. proto.unix = unix;
  4281. proto.valueOf = valueOf;
  4282. proto.creationData = creationData;
  4283. proto.eraName = getEraName;
  4284. proto.eraNarrow = getEraNarrow;
  4285. proto.eraAbbr = getEraAbbr;
  4286. proto.eraYear = getEraYear;
  4287. proto.year = getSetYear;
  4288. proto.isLeapYear = getIsLeapYear;
  4289. proto.weekYear = getSetWeekYear;
  4290. proto.isoWeekYear = getSetISOWeekYear;
  4291. proto.quarter = proto.quarters = getSetQuarter;
  4292. proto.month = getSetMonth;
  4293. proto.daysInMonth = getDaysInMonth;
  4294. proto.week = proto.weeks = getSetWeek;
  4295. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  4296. proto.weeksInYear = getWeeksInYear;
  4297. proto.weeksInWeekYear = getWeeksInWeekYear;
  4298. proto.isoWeeksInYear = getISOWeeksInYear;
  4299. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  4300. proto.date = getSetDayOfMonth;
  4301. proto.day = proto.days = getSetDayOfWeek;
  4302. proto.weekday = getSetLocaleDayOfWeek;
  4303. proto.isoWeekday = getSetISODayOfWeek;
  4304. proto.dayOfYear = getSetDayOfYear;
  4305. proto.hour = proto.hours = getSetHour;
  4306. proto.minute = proto.minutes = getSetMinute;
  4307. proto.second = proto.seconds = getSetSecond;
  4308. proto.millisecond = proto.milliseconds = getSetMillisecond;
  4309. proto.utcOffset = getSetOffset;
  4310. proto.utc = setOffsetToUTC;
  4311. proto.local = setOffsetToLocal;
  4312. proto.parseZone = setOffsetToParsedOffset;
  4313. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  4314. proto.isDST = isDaylightSavingTime;
  4315. proto.isLocal = isLocal;
  4316. proto.isUtcOffset = isUtcOffset;
  4317. proto.isUtc = isUtc;
  4318. proto.isUTC = isUtc;
  4319. proto.zoneAbbr = getZoneAbbr;
  4320. proto.zoneName = getZoneName;
  4321. proto.dates = deprecate(
  4322. 'dates accessor is deprecated. Use date instead.',
  4323. getSetDayOfMonth
  4324. );
  4325. proto.months = deprecate(
  4326. 'months accessor is deprecated. Use month instead',
  4327. getSetMonth
  4328. );
  4329. proto.years = deprecate(
  4330. 'years accessor is deprecated. Use year instead',
  4331. getSetYear
  4332. );
  4333. proto.zone = deprecate(
  4334. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  4335. getSetZone
  4336. );
  4337. proto.isDSTShifted = deprecate(
  4338. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  4339. isDaylightSavingTimeShifted
  4340. );
  4341. function createUnix(input) {
  4342. return createLocal(input * 1000);
  4343. }
  4344. function createInZone() {
  4345. return createLocal.apply(null, arguments).parseZone();
  4346. }
  4347. function preParsePostFormat(string) {
  4348. return string;
  4349. }
  4350. var proto$1 = Locale.prototype;
  4351. proto$1.calendar = calendar;
  4352. proto$1.longDateFormat = longDateFormat;
  4353. proto$1.invalidDate = invalidDate;
  4354. proto$1.ordinal = ordinal;
  4355. proto$1.preparse = preParsePostFormat;
  4356. proto$1.postformat = preParsePostFormat;
  4357. proto$1.relativeTime = relativeTime;
  4358. proto$1.pastFuture = pastFuture;
  4359. proto$1.set = set;
  4360. proto$1.eras = localeEras;
  4361. proto$1.erasParse = localeErasParse;
  4362. proto$1.erasConvertYear = localeErasConvertYear;
  4363. proto$1.erasAbbrRegex = erasAbbrRegex;
  4364. proto$1.erasNameRegex = erasNameRegex;
  4365. proto$1.erasNarrowRegex = erasNarrowRegex;
  4366. proto$1.months = localeMonths;
  4367. proto$1.monthsShort = localeMonthsShort;
  4368. proto$1.monthsParse = localeMonthsParse;
  4369. proto$1.monthsRegex = monthsRegex;
  4370. proto$1.monthsShortRegex = monthsShortRegex;
  4371. proto$1.week = localeWeek;
  4372. proto$1.firstDayOfYear = localeFirstDayOfYear;
  4373. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  4374. proto$1.weekdays = localeWeekdays;
  4375. proto$1.weekdaysMin = localeWeekdaysMin;
  4376. proto$1.weekdaysShort = localeWeekdaysShort;
  4377. proto$1.weekdaysParse = localeWeekdaysParse;
  4378. proto$1.weekdaysRegex = weekdaysRegex;
  4379. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  4380. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  4381. proto$1.isPM = localeIsPM;
  4382. proto$1.meridiem = localeMeridiem;
  4383. function get$1(format, index, field, setter) {
  4384. var locale = getLocale(),
  4385. utc = createUTC().set(setter, index);
  4386. return locale[field](utc, format);
  4387. }
  4388. function listMonthsImpl(format, index, field) {
  4389. if (isNumber(format)) {
  4390. index = format;
  4391. format = undefined;
  4392. }
  4393. format = format || '';
  4394. if (index != null) {
  4395. return get$1(format, index, field, 'month');
  4396. }
  4397. var i,
  4398. out = [];
  4399. for (i = 0; i < 12; i++) {
  4400. out[i] = get$1(format, i, field, 'month');
  4401. }
  4402. return out;
  4403. }
  4404. // ()
  4405. // (5)
  4406. // (fmt, 5)
  4407. // (fmt)
  4408. // (true)
  4409. // (true, 5)
  4410. // (true, fmt, 5)
  4411. // (true, fmt)
  4412. function listWeekdaysImpl(localeSorted, format, index, field) {
  4413. if (typeof localeSorted === 'boolean') {
  4414. if (isNumber(format)) {
  4415. index = format;
  4416. format = undefined;
  4417. }
  4418. format = format || '';
  4419. } else {
  4420. format = localeSorted;
  4421. index = format;
  4422. localeSorted = false;
  4423. if (isNumber(format)) {
  4424. index = format;
  4425. format = undefined;
  4426. }
  4427. format = format || '';
  4428. }
  4429. var locale = getLocale(),
  4430. shift = localeSorted ? locale._week.dow : 0,
  4431. i,
  4432. out = [];
  4433. if (index != null) {
  4434. return get$1(format, (index + shift) % 7, field, 'day');
  4435. }
  4436. for (i = 0; i < 7; i++) {
  4437. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  4438. }
  4439. return out;
  4440. }
  4441. function listMonths(format, index) {
  4442. return listMonthsImpl(format, index, 'months');
  4443. }
  4444. function listMonthsShort(format, index) {
  4445. return listMonthsImpl(format, index, 'monthsShort');
  4446. }
  4447. function listWeekdays(localeSorted, format, index) {
  4448. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  4449. }
  4450. function listWeekdaysShort(localeSorted, format, index) {
  4451. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  4452. }
  4453. function listWeekdaysMin(localeSorted, format, index) {
  4454. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  4455. }
  4456. getSetGlobalLocale('en', {
  4457. eras: [
  4458. {
  4459. since: '0001-01-01',
  4460. until: +Infinity,
  4461. offset: 1,
  4462. name: 'Anno Domini',
  4463. narrow: 'AD',
  4464. abbr: 'AD',
  4465. },
  4466. {
  4467. since: '0000-12-31',
  4468. until: -Infinity,
  4469. offset: 1,
  4470. name: 'Before Christ',
  4471. narrow: 'BC',
  4472. abbr: 'BC',
  4473. },
  4474. ],
  4475. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  4476. ordinal: function (number) {
  4477. var b = number % 10,
  4478. output =
  4479. toInt((number % 100) / 10) === 1
  4480. ? 'th'
  4481. : b === 1
  4482. ? 'st'
  4483. : b === 2
  4484. ? 'nd'
  4485. : b === 3
  4486. ? 'rd'
  4487. : 'th';
  4488. return number + output;
  4489. },
  4490. });
  4491. // Side effect imports
  4492. hooks.lang = deprecate(
  4493. 'moment.lang is deprecated. Use moment.locale instead.',
  4494. getSetGlobalLocale
  4495. );
  4496. hooks.langData = deprecate(
  4497. 'moment.langData is deprecated. Use moment.localeData instead.',
  4498. getLocale
  4499. );
  4500. var mathAbs = Math.abs;
  4501. function abs() {
  4502. var data = this._data;
  4503. this._milliseconds = mathAbs(this._milliseconds);
  4504. this._days = mathAbs(this._days);
  4505. this._months = mathAbs(this._months);
  4506. data.milliseconds = mathAbs(data.milliseconds);
  4507. data.seconds = mathAbs(data.seconds);
  4508. data.minutes = mathAbs(data.minutes);
  4509. data.hours = mathAbs(data.hours);
  4510. data.months = mathAbs(data.months);
  4511. data.years = mathAbs(data.years);
  4512. return this;
  4513. }
  4514. function addSubtract$1(duration, input, value, direction) {
  4515. var other = createDuration(input, value);
  4516. duration._milliseconds += direction * other._milliseconds;
  4517. duration._days += direction * other._days;
  4518. duration._months += direction * other._months;
  4519. return duration._bubble();
  4520. }
  4521. // supports only 2.0-style add(1, 's') or add(duration)
  4522. function add$1(input, value) {
  4523. return addSubtract$1(this, input, value, 1);
  4524. }
  4525. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  4526. function subtract$1(input, value) {
  4527. return addSubtract$1(this, input, value, -1);
  4528. }
  4529. function absCeil(number) {
  4530. if (number < 0) {
  4531. return Math.floor(number);
  4532. } else {
  4533. return Math.ceil(number);
  4534. }
  4535. }
  4536. function bubble() {
  4537. var milliseconds = this._milliseconds,
  4538. days = this._days,
  4539. months = this._months,
  4540. data = this._data,
  4541. seconds,
  4542. minutes,
  4543. hours,
  4544. years,
  4545. monthsFromDays;
  4546. // if we have a mix of positive and negative values, bubble down first
  4547. // check: https://github.com/moment/moment/issues/2166
  4548. if (
  4549. !(
  4550. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  4551. (milliseconds <= 0 && days <= 0 && months <= 0)
  4552. )
  4553. ) {
  4554. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  4555. days = 0;
  4556. months = 0;
  4557. }
  4558. // The following code bubbles up values, see the tests for
  4559. // examples of what that means.
  4560. data.milliseconds = milliseconds % 1000;
  4561. seconds = absFloor(milliseconds / 1000);
  4562. data.seconds = seconds % 60;
  4563. minutes = absFloor(seconds / 60);
  4564. data.minutes = minutes % 60;
  4565. hours = absFloor(minutes / 60);
  4566. data.hours = hours % 24;
  4567. days += absFloor(hours / 24);
  4568. // convert days to months
  4569. monthsFromDays = absFloor(daysToMonths(days));
  4570. months += monthsFromDays;
  4571. days -= absCeil(monthsToDays(monthsFromDays));
  4572. // 12 months -> 1 year
  4573. years = absFloor(months / 12);
  4574. months %= 12;
  4575. data.days = days;
  4576. data.months = months;
  4577. data.years = years;
  4578. return this;
  4579. }
  4580. function daysToMonths(days) {
  4581. // 400 years have 146097 days (taking into account leap year rules)
  4582. // 400 years have 12 months === 4800
  4583. return (days * 4800) / 146097;
  4584. }
  4585. function monthsToDays(months) {
  4586. // the reverse of daysToMonths
  4587. return (months * 146097) / 4800;
  4588. }
  4589. function as(units) {
  4590. if (!this.isValid()) {
  4591. return NaN;
  4592. }
  4593. var days,
  4594. months,
  4595. milliseconds = this._milliseconds;
  4596. units = normalizeUnits(units);
  4597. if (units === 'month' || units === 'quarter' || units === 'year') {
  4598. days = this._days + milliseconds / 864e5;
  4599. months = this._months + daysToMonths(days);
  4600. switch (units) {
  4601. case 'month':
  4602. return months;
  4603. case 'quarter':
  4604. return months / 3;
  4605. case 'year':
  4606. return months / 12;
  4607. }
  4608. } else {
  4609. // handle milliseconds separately because of floating point math errors (issue #1867)
  4610. days = this._days + Math.round(monthsToDays(this._months));
  4611. switch (units) {
  4612. case 'week':
  4613. return days / 7 + milliseconds / 6048e5;
  4614. case 'day':
  4615. return days + milliseconds / 864e5;
  4616. case 'hour':
  4617. return days * 24 + milliseconds / 36e5;
  4618. case 'minute':
  4619. return days * 1440 + milliseconds / 6e4;
  4620. case 'second':
  4621. return days * 86400 + milliseconds / 1000;
  4622. // Math.floor prevents floating point math errors here
  4623. case 'millisecond':
  4624. return Math.floor(days * 864e5) + milliseconds;
  4625. default:
  4626. throw new Error('Unknown unit ' + units);
  4627. }
  4628. }
  4629. }
  4630. // TODO: Use this.as('ms')?
  4631. function valueOf$1() {
  4632. if (!this.isValid()) {
  4633. return NaN;
  4634. }
  4635. return (
  4636. this._milliseconds +
  4637. this._days * 864e5 +
  4638. (this._months % 12) * 2592e6 +
  4639. toInt(this._months / 12) * 31536e6
  4640. );
  4641. }
  4642. function makeAs(alias) {
  4643. return function () {
  4644. return this.as(alias);
  4645. };
  4646. }
  4647. var asMilliseconds = makeAs('ms'),
  4648. asSeconds = makeAs('s'),
  4649. asMinutes = makeAs('m'),
  4650. asHours = makeAs('h'),
  4651. asDays = makeAs('d'),
  4652. asWeeks = makeAs('w'),
  4653. asMonths = makeAs('M'),
  4654. asQuarters = makeAs('Q'),
  4655. asYears = makeAs('y');
  4656. function clone$1() {
  4657. return createDuration(this);
  4658. }
  4659. function get$2(units) {
  4660. units = normalizeUnits(units);
  4661. return this.isValid() ? this[units + 's']() : NaN;
  4662. }
  4663. function makeGetter(name) {
  4664. return function () {
  4665. return this.isValid() ? this._data[name] : NaN;
  4666. };
  4667. }
  4668. var milliseconds = makeGetter('milliseconds'),
  4669. seconds = makeGetter('seconds'),
  4670. minutes = makeGetter('minutes'),
  4671. hours = makeGetter('hours'),
  4672. days = makeGetter('days'),
  4673. months = makeGetter('months'),
  4674. years = makeGetter('years');
  4675. function weeks() {
  4676. return absFloor(this.days() / 7);
  4677. }
  4678. var round = Math.round,
  4679. thresholds = {
  4680. ss: 44, // a few seconds to seconds
  4681. s: 45, // seconds to minute
  4682. m: 45, // minutes to hour
  4683. h: 22, // hours to day
  4684. d: 26, // days to month/week
  4685. w: null, // weeks to month
  4686. M: 11, // months to year
  4687. };
  4688. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  4689. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  4690. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  4691. }
  4692. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  4693. var duration = createDuration(posNegDuration).abs(),
  4694. seconds = round(duration.as('s')),
  4695. minutes = round(duration.as('m')),
  4696. hours = round(duration.as('h')),
  4697. days = round(duration.as('d')),
  4698. months = round(duration.as('M')),
  4699. weeks = round(duration.as('w')),
  4700. years = round(duration.as('y')),
  4701. a =
  4702. (seconds <= thresholds.ss && ['s', seconds]) ||
  4703. (seconds < thresholds.s && ['ss', seconds]) ||
  4704. (minutes <= 1 && ['m']) ||
  4705. (minutes < thresholds.m && ['mm', minutes]) ||
  4706. (hours <= 1 && ['h']) ||
  4707. (hours < thresholds.h && ['hh', hours]) ||
  4708. (days <= 1 && ['d']) ||
  4709. (days < thresholds.d && ['dd', days]);
  4710. if (thresholds.w != null) {
  4711. a =
  4712. a ||
  4713. (weeks <= 1 && ['w']) ||
  4714. (weeks < thresholds.w && ['ww', weeks]);
  4715. }
  4716. a = a ||
  4717. (months <= 1 && ['M']) ||
  4718. (months < thresholds.M && ['MM', months]) ||
  4719. (years <= 1 && ['y']) || ['yy', years];
  4720. a[2] = withoutSuffix;
  4721. a[3] = +posNegDuration > 0;
  4722. a[4] = locale;
  4723. return substituteTimeAgo.apply(null, a);
  4724. }
  4725. // This function allows you to set the rounding function for relative time strings
  4726. function getSetRelativeTimeRounding(roundingFunction) {
  4727. if (roundingFunction === undefined) {
  4728. return round;
  4729. }
  4730. if (typeof roundingFunction === 'function') {
  4731. round = roundingFunction;
  4732. return true;
  4733. }
  4734. return false;
  4735. }
  4736. // This function allows you to set a threshold for relative time strings
  4737. function getSetRelativeTimeThreshold(threshold, limit) {
  4738. if (thresholds[threshold] === undefined) {
  4739. return false;
  4740. }
  4741. if (limit === undefined) {
  4742. return thresholds[threshold];
  4743. }
  4744. thresholds[threshold] = limit;
  4745. if (threshold === 's') {
  4746. thresholds.ss = limit - 1;
  4747. }
  4748. return true;
  4749. }
  4750. function humanize(argWithSuffix, argThresholds) {
  4751. if (!this.isValid()) {
  4752. return this.localeData().invalidDate();
  4753. }
  4754. var withSuffix = false,
  4755. th = thresholds,
  4756. locale,
  4757. output;
  4758. if (typeof argWithSuffix === 'object') {
  4759. argThresholds = argWithSuffix;
  4760. argWithSuffix = false;
  4761. }
  4762. if (typeof argWithSuffix === 'boolean') {
  4763. withSuffix = argWithSuffix;
  4764. }
  4765. if (typeof argThresholds === 'object') {
  4766. th = Object.assign({}, thresholds, argThresholds);
  4767. if (argThresholds.s != null && argThresholds.ss == null) {
  4768. th.ss = argThresholds.s - 1;
  4769. }
  4770. }
  4771. locale = this.localeData();
  4772. output = relativeTime$1(this, !withSuffix, th, locale);
  4773. if (withSuffix) {
  4774. output = locale.pastFuture(+this, output);
  4775. }
  4776. return locale.postformat(output);
  4777. }
  4778. var abs$1 = Math.abs;
  4779. function sign(x) {
  4780. return (x > 0) - (x < 0) || +x;
  4781. }
  4782. function toISOString$1() {
  4783. // for ISO strings we do not use the normal bubbling rules:
  4784. // * milliseconds bubble up until they become hours
  4785. // * days do not bubble at all
  4786. // * months bubble up until they become years
  4787. // This is because there is no context-free conversion between hours and days
  4788. // (think of clock changes)
  4789. // and also not between days and months (28-31 days per month)
  4790. if (!this.isValid()) {
  4791. return this.localeData().invalidDate();
  4792. }
  4793. var seconds = abs$1(this._milliseconds) / 1000,
  4794. days = abs$1(this._days),
  4795. months = abs$1(this._months),
  4796. minutes,
  4797. hours,
  4798. years,
  4799. s,
  4800. total = this.asSeconds(),
  4801. totalSign,
  4802. ymSign,
  4803. daysSign,
  4804. hmsSign;
  4805. if (!total) {
  4806. // this is the same as C#'s (Noda) and python (isodate)...
  4807. // but not other JS (goog.date)
  4808. return 'P0D';
  4809. }
  4810. // 3600 seconds -> 60 minutes -> 1 hour
  4811. minutes = absFloor(seconds / 60);
  4812. hours = absFloor(minutes / 60);
  4813. seconds %= 60;
  4814. minutes %= 60;
  4815. // 12 months -> 1 year
  4816. years = absFloor(months / 12);
  4817. months %= 12;
  4818. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  4819. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  4820. totalSign = total < 0 ? '-' : '';
  4821. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  4822. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  4823. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  4824. return (
  4825. totalSign +
  4826. 'P' +
  4827. (years ? ymSign + years + 'Y' : '') +
  4828. (months ? ymSign + months + 'M' : '') +
  4829. (days ? daysSign + days + 'D' : '') +
  4830. (hours || minutes || seconds ? 'T' : '') +
  4831. (hours ? hmsSign + hours + 'H' : '') +
  4832. (minutes ? hmsSign + minutes + 'M' : '') +
  4833. (seconds ? hmsSign + s + 'S' : '')
  4834. );
  4835. }
  4836. var proto$2 = Duration.prototype;
  4837. proto$2.isValid = isValid$1;
  4838. proto$2.abs = abs;
  4839. proto$2.add = add$1;
  4840. proto$2.subtract = subtract$1;
  4841. proto$2.as = as;
  4842. proto$2.asMilliseconds = asMilliseconds;
  4843. proto$2.asSeconds = asSeconds;
  4844. proto$2.asMinutes = asMinutes;
  4845. proto$2.asHours = asHours;
  4846. proto$2.asDays = asDays;
  4847. proto$2.asWeeks = asWeeks;
  4848. proto$2.asMonths = asMonths;
  4849. proto$2.asQuarters = asQuarters;
  4850. proto$2.asYears = asYears;
  4851. proto$2.valueOf = valueOf$1;
  4852. proto$2._bubble = bubble;
  4853. proto$2.clone = clone$1;
  4854. proto$2.get = get$2;
  4855. proto$2.milliseconds = milliseconds;
  4856. proto$2.seconds = seconds;
  4857. proto$2.minutes = minutes;
  4858. proto$2.hours = hours;
  4859. proto$2.days = days;
  4860. proto$2.weeks = weeks;
  4861. proto$2.months = months;
  4862. proto$2.years = years;
  4863. proto$2.humanize = humanize;
  4864. proto$2.toISOString = toISOString$1;
  4865. proto$2.toString = toISOString$1;
  4866. proto$2.toJSON = toISOString$1;
  4867. proto$2.locale = locale;
  4868. proto$2.localeData = localeData;
  4869. proto$2.toIsoString = deprecate(
  4870. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  4871. toISOString$1
  4872. );
  4873. proto$2.lang = lang;
  4874. // FORMATTING
  4875. addFormatToken('X', 0, 0, 'unix');
  4876. addFormatToken('x', 0, 0, 'valueOf');
  4877. // PARSING
  4878. addRegexToken('x', matchSigned);
  4879. addRegexToken('X', matchTimestamp);
  4880. addParseToken('X', function (input, array, config) {
  4881. config._d = new Date(parseFloat(input) * 1000);
  4882. });
  4883. addParseToken('x', function (input, array, config) {
  4884. config._d = new Date(toInt(input));
  4885. });
  4886. //! moment.js
  4887. hooks.version = '2.29.4';
  4888. setHookCallback(createLocal);
  4889. hooks.fn = proto;
  4890. hooks.min = min;
  4891. hooks.max = max;
  4892. hooks.now = now;
  4893. hooks.utc = createUTC;
  4894. hooks.unix = createUnix;
  4895. hooks.months = listMonths;
  4896. hooks.isDate = isDate;
  4897. hooks.locale = getSetGlobalLocale;
  4898. hooks.invalid = createInvalid;
  4899. hooks.duration = createDuration;
  4900. hooks.isMoment = isMoment;
  4901. hooks.weekdays = listWeekdays;
  4902. hooks.parseZone = createInZone;
  4903. hooks.localeData = getLocale;
  4904. hooks.isDuration = isDuration;
  4905. hooks.monthsShort = listMonthsShort;
  4906. hooks.weekdaysMin = listWeekdaysMin;
  4907. hooks.defineLocale = defineLocale;
  4908. hooks.updateLocale = updateLocale;
  4909. hooks.locales = listLocales;
  4910. hooks.weekdaysShort = listWeekdaysShort;
  4911. hooks.normalizeUnits = normalizeUnits;
  4912. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  4913. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  4914. hooks.calendarFormat = getCalendarFormat;
  4915. hooks.prototype = proto;
  4916. // currently HTML5 input type only supports 24-hour formats
  4917. hooks.HTML5_FMT = {
  4918. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  4919. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  4920. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  4921. DATE: 'YYYY-MM-DD', // <input type="date" />
  4922. TIME: 'HH:mm', // <input type="time" />
  4923. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  4924. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  4925. WEEK: 'GGGG-[W]WW', // <input type="week" />
  4926. MONTH: 'YYYY-MM', // <input type="month" />
  4927. };
  4928. return hooks;
  4929. })));