moment.js 170 KB

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