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