@docsvision/material-ui-pickers 3.2.0-beta.28 → 3.2.0-beta.29

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