index.js 172 KB

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