4536 lines · 140.9 KB · JavaScript
RawDownload
//! moment.js//! version : 2.20.1//! authors : Tim Wood, Iskren Chernev, Moment.js contributors//! license : MIT//! momentjs.com ; (function (global, factory) {    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :    typeof define === 'function' && define.amd ? define(factory) :    global.moment = factory()}(this, (function () {    'use strict';     var hookCallback;     function hooks() {        return hookCallback.apply(null, arguments);    }     // This is done to register the method called with moment()    // without creating circular dependencies.    function setHookCallback(callback) {        hookCallback = callback;    }     function isArray(input) {        return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';    }     function isObject(input) {        // IE8 will treat undefined and null as object if it wasn't for        // input != null        return input != null && Object.prototype.toString.call(input) === '[object Object]';    }     function isObjectEmpty(obj) {        if (Object.getOwnPropertyNames) {            return (Object.getOwnPropertyNames(obj).length === 0);        } else {            var k;            for (k in obj) {                if (obj.hasOwnProperty(k)) {                    return false;                }            }            return true;        }    }     function isUndefined(input) {        return input === void 0;    }     function isNumber(input) {        return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';    }     function isDate(input) {        return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';    }     function map(arr, fn) {        var res = [], i;        for (i = 0; i < arr.length; ++i) {            res.push(fn(arr[i], i));        }        return res;    }     function hasOwnProp(a, b) {        return Object.prototype.hasOwnProperty.call(a, b);    }     function extend(a, b) {        for (var i in b) {            if (hasOwnProp(b, i)) {                a[i] = b[i];            }        }         if (hasOwnProp(b, 'toString')) {            a.toString = b.toString;        }         if (hasOwnProp(b, 'valueOf')) {            a.valueOf = b.valueOf;        }         return a;    }     function createUTC(input, format, locale, strict) {        return createLocalOrUTC(input, format, locale, strict, true).utc();    }     function defaultParsingFlags() {        // We need to deep clone this object.        return {            empty: false,            unusedTokens: [],            unusedInput: [],            overflow: -2,            charsLeftOver: 0,            nullInput: false,            invalidMonth: null,            invalidFormat: false,            userInvalidated: false,            iso: false,            parsedDateParts: [],            meridiem: null,            rfc2822: false,            weekdayMismatch: false        };    }     function getParsingFlags(m) {        if (m._pf == null) {            m._pf = defaultParsingFlags();        }        return m._pf;    }     var some;    if (Array.prototype.some) {        some = Array.prototype.some;    } else {        some = function (fun) {            var t = Object(this);            var len = t.length >>> 0;             for (var i = 0; i < len; i++) {                if (i in t && fun.call(this, t[i], i, t)) {                    return true;                }            }             return false;        };    }     function isValid(m) {        if (m._isValid == null) {            var flags = getParsingFlags(m);            var parsedParts = some.call(flags.parsedDateParts, function (i) {                return i != null;            });            var isNowValid = !isNaN(m._d.getTime()) &&                flags.overflow < 0 &&                !flags.empty &&                !flags.invalidMonth &&                !flags.invalidWeekday &&                !flags.weekdayMismatch &&                !flags.nullInput &&                !flags.invalidFormat &&                !flags.userInvalidated &&                (!flags.meridiem || (flags.meridiem && parsedParts));             if (m._strict) {                isNowValid = isNowValid &&                    flags.charsLeftOver === 0 &&                    flags.unusedTokens.length === 0 &&                    flags.bigHour === undefined;            }             if (Object.isFrozen == null || !Object.isFrozen(m)) {                m._isValid = isNowValid;            }            else {                return isNowValid;            }        }        return m._isValid;    }     function createInvalid(flags) {        var m = createUTC(NaN);        if (flags != null) {            extend(getParsingFlags(m), flags);        }        else {            getParsingFlags(m).userInvalidated = true;        }         return m;    }     // Plugins that add properties should also add the key here (null value),    // so we can properly clone ourselves.    var momentProperties = hooks.momentProperties = [];     function copyConfig(to, from) {        var i, prop, val;         if (!isUndefined(from._isAMomentObject)) {            to._isAMomentObject = from._isAMomentObject;        }        if (!isUndefined(from._i)) {            to._i = from._i;        }        if (!isUndefined(from._f)) {            to._f = from._f;        }        if (!isUndefined(from._l)) {            to._l = from._l;        }        if (!isUndefined(from._strict)) {            to._strict = from._strict;        }        if (!isUndefined(from._tzm)) {            to._tzm = from._tzm;        }        if (!isUndefined(from._isUTC)) {            to._isUTC = from._isUTC;        }        if (!isUndefined(from._offset)) {            to._offset = from._offset;        }        if (!isUndefined(from._pf)) {            to._pf = getParsingFlags(from);        }        if (!isUndefined(from._locale)) {            to._locale = from._locale;        }         if (momentProperties.length > 0) {            for (i = 0; i < momentProperties.length; i++) {                prop = momentProperties[i];                val = from[prop];                if (!isUndefined(val)) {                    to[prop] = val;                }            }        }         return to;    }     var updateInProgress = false;     // Moment prototype object    function Moment(config) {        copyConfig(this, config);        this._d = new Date(config._d != null ? config._d.getTime() : NaN);        if (!this.isValid()) {            this._d = new Date(NaN);        }        // Prevent infinite loop in case updateOffset creates new moment        // objects.        if (updateInProgress === false) {            updateInProgress = true;            hooks.updateOffset(this);            updateInProgress = false;        }    }     function isMoment(obj) {        return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);    }     function absFloor(number) {        if (number < 0) {            // -0 -> 0            return Math.ceil(number) || 0;        } else {            return Math.floor(number);        }    }     function toInt(argumentForCoercion) {        var coercedNumber = +argumentForCoercion,            value = 0;         if (coercedNumber !== 0 && isFinite(coercedNumber)) {            value = absFloor(coercedNumber);        }         return value;    }     // compare two arrays, return the number of differences    function compareArrays(array1, array2, dontConvert) {        var len = Math.min(array1.length, array2.length),            lengthDiff = Math.abs(array1.length - array2.length),            diffs = 0,            i;        for (i = 0; i < len; i++) {            if ((dontConvert && array1[i] !== array2[i]) ||                (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {                diffs++;            }        }        return diffs + lengthDiff;    }     function warn(msg) {        if (hooks.suppressDeprecationWarnings === false &&                (typeof console !== 'undefined') && console.warn) {            console.warn('Deprecation warning: ' + msg);        }    }     function deprecate(msg, fn) {        var firstTime = true;         return extend(function () {            if (hooks.deprecationHandler != null) {                hooks.deprecationHandler(null, msg);            }            if (firstTime) {                var args = [];                var arg;                for (var i = 0; i < arguments.length; i++) {                    arg = '';                    if (typeof arguments[i] === 'object') {                        arg += '\n[' + i + '] ';                        for (var key in arguments[0]) {                            arg += key + ': ' + arguments[0][key] + ', ';                        }                        arg = arg.slice(0, -2); // Remove trailing comma and space                    } else {                        arg = arguments[i];                    }                    args.push(arg);                }                warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);                firstTime = false;            }            return fn.apply(this, arguments);        }, fn);    }     var deprecations = {};     function deprecateSimple(name, msg) {        if (hooks.deprecationHandler != null) {            hooks.deprecationHandler(name, msg);        }        if (!deprecations[name]) {            warn(msg);            deprecations[name] = true;        }    }     hooks.suppressDeprecationWarnings = false;    hooks.deprecationHandler = null;     function isFunction(input) {        return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';    }     function set(config) {        var prop, i;        for (i in config) {            prop = config[i];            if (isFunction(prop)) {                this[i] = prop;            } else {                this['_' + i] = prop;            }        }        this._config = config;        // Lenient ordinal parsing accepts just a number in addition to        // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.        // TODO: Remove "ordinalParse" fallback in next major release.        this._dayOfMonthOrdinalParseLenient = new RegExp(            (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +                '|' + (/\d{1,2}/).source);    }     function mergeConfigs(parentConfig, childConfig) {        var res = extend({}, parentConfig), prop;        for (prop in childConfig) {            if (hasOwnProp(childConfig, prop)) {                if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {                    res[prop] = {};                    extend(res[prop], parentConfig[prop]);                    extend(res[prop], childConfig[prop]);                } else if (childConfig[prop] != null) {                    res[prop] = childConfig[prop];                } else {                    delete res[prop];                }            }        }        for (prop in parentConfig) {            if (hasOwnProp(parentConfig, prop) &&                    !hasOwnProp(childConfig, prop) &&                    isObject(parentConfig[prop])) {                // make sure changes to properties don't modify parent config                res[prop] = extend({}, res[prop]);            }        }        return res;    }     function Locale(config) {        if (config != null) {            this.set(config);        }    }     var keys;     if (Object.keys) {        keys = Object.keys;    } else {        keys = function (obj) {            var i, res = [];            for (i in obj) {                if (hasOwnProp(obj, i)) {                    res.push(i);                }            }            return res;        };    }     var defaultCalendar = {        sameDay: '[Today at] LT',        nextDay: '[Tomorrow at] LT',        nextWeek: 'dddd [at] LT',        lastDay: '[Yesterday at] LT',        lastWeek: '[Last] dddd [at] LT',        sameElse: 'L'    };     function calendar(key, mom, now) {        var output = this._calendar[key] || this._calendar['sameElse'];        return isFunction(output) ? output.call(mom, now) : output;    }     var defaultLongDateFormat = {        LTS: 'h:mm:ss A',        LT: 'h:mm A',        L: 'MM/DD/YYYY',        LL: 'MMMM D, YYYY',        LLL: 'MMMM D, YYYY h:mm A',        LLLL: 'dddd, MMMM D, YYYY h:mm A'    };     function longDateFormat(key) {        var format = this._longDateFormat[key],            formatUpper = this._longDateFormat[key.toUpperCase()];         if (format || !formatUpper) {            return format;        }         this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {            return val.slice(1);        });         return this._longDateFormat[key];    }     var defaultInvalidDate = 'Invalid date';     function invalidDate() {        return this._invalidDate;    }     var defaultOrdinal = '%d';    var defaultDayOfMonthOrdinalParse = /\d{1,2}/;     function ordinal(number) {        return this._ordinal.replace('%d', number);    }     var defaultRelativeTime = {        future: 'in %s',        past: '%s ago',        s: 'a few seconds',        ss: '%d seconds',        m: 'a minute',        mm: '%d minutes',        h: 'an hour',        hh: '%d hours',        d: 'a day',        dd: '%d days',        M: 'a month',        MM: '%d months',        y: 'a year',        yy: '%d years'    };     function relativeTime(number, withoutSuffix, string, isFuture) {        var output = this._relativeTime[string];        return (isFunction(output)) ?            output(number, withoutSuffix, string, isFuture) :            output.replace(/%d/i, number);    }     function pastFuture(diff, output) {        var format = this._relativeTime[diff > 0 ? 'future' : 'past'];        return isFunction(format) ? format(output) : format.replace(/%s/i, output);    }     var aliases = {};     function addUnitAlias(unit, shorthand) {

Lines 1–500 of 4536.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t