1
lxl
2022-09-16 cb746cca26fa024018d7ce772ba6a96557ea768b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { hooks } from '../utils/hooks';
import hasOwnProp from '../utils/has-own-prop';
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 = [];
 
export function copyConfig(to, from) {
    var i, prop, val;
 
    if (typeof from._isAMomentObject !== 'undefined') {
        to._isAMomentObject = from._isAMomentObject;
    }
    if (typeof from._i !== 'undefined') {
        to._i = from._i;
    }
    if (typeof from._f !== 'undefined') {
        to._f = from._f;
    }
    if (typeof from._l !== 'undefined') {
        to._l = from._l;
    }
    if (typeof from._strict !== 'undefined') {
        to._strict = from._strict;
    }
    if (typeof from._tzm !== 'undefined') {
        to._tzm = from._tzm;
    }
    if (typeof from._isUTC !== 'undefined') {
        to._isUTC = from._isUTC;
    }
    if (typeof from._offset !== 'undefined') {
        to._offset = from._offset;
    }
    if (typeof from._pf !== 'undefined') {
        to._pf = getParsingFlags(from);
    }
    if (typeof from._locale !== 'undefined') {
        to._locale = from._locale;
    }
 
    if (momentProperties.length > 0) {
        for (i in momentProperties) {
            prop = momentProperties[i];
            val = from[prop];
            if (typeof val !== 'undefined') {
                to[prop] = val;
            }
        }
    }
 
    return to;
}
 
var updateInProgress = false;
 
// Moment prototype object
export function Moment(config) {
    copyConfig(this, config);
    this._d = new Date(config._d != null ? config._d.getTime() : 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);
}