Sha256: 86a11f9b265ea25e692b3454ad2810e70cb71b33361ec118d78f31945b525dc8

Contents?: true

Size: 2 KB

Versions: 19

Compression:

Stored size: 2 KB

Contents

import { hooks } from '../utils/hooks';
import isUndefined from '../utils/is-undefined';
import getParsingFlags from '../create/parsing-flags';

// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = (hooks.momentProperties = []),
    updateInProgress = false;

export 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;
}

// Moment prototype object
export 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;
    }
}

export function isMoment(obj) {
    return (
        obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
    );
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-mod-date-0.15.6 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.15.0 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.14.2 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.14.1 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.14.0 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.13.4 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.13.3 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.13.2 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.13.1 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.13.0 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.7 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.12.0 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.6 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.5 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.4 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.3 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.2 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.1 vendor/moment/src/lib/moment/constructor.js
card-mod-date-0.11.0 vendor/moment/src/lib/moment/constructor.js