PageSourceSearch

https://fedway.com/fedway85ThemeStatic/themes/Fedway85/js/moment.js

js fedway.com collected 2026-10-04 00:59:09 UTC 155,539 bytes, 4,601 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.