MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / Duration

Function Duration

tests/test_code/js/moment/moment.js:3140–3173  ·  view source on GitHub ↗
(duration)

Source from the content-addressed store, hash-verified

3138 }
3139
3140 function Duration(duration) {
3141 var normalizedInput = normalizeObjectUnits(duration),
3142 years = normalizedInput.year || 0,
3143 quarters = normalizedInput.quarter || 0,
3144 months = normalizedInput.month || 0,
3145 weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
3146 days = normalizedInput.day || 0,
3147 hours = normalizedInput.hour || 0,
3148 minutes = normalizedInput.minute || 0,
3149 seconds = normalizedInput.second || 0,
3150 milliseconds = normalizedInput.millisecond || 0;
3151
3152 this._isValid = isDurationValid(normalizedInput);
3153
3154 // representation for dateAddRemove
3155 this._milliseconds =
3156 +milliseconds +
3157 seconds * 1e3 + // 1000
3158 minutes * 6e4 + // 1000 * 60
3159 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
3160 // Because of dateAddRemove treats 24 hours as different from a
3161 // day when working around DST, we need to store them separately
3162 this._days = +days + weeks * 7;
3163 // It is impossible to translate months into days without knowing
3164 // which months you are are talking about, so we have to store
3165 // it separately.
3166 this._months = +months + quarters * 3 + years * 12;
3167
3168 this._data = {};
3169
3170 this._locale = getLocale();
3171
3172 this._bubble();
3173 }
3174
3175 function isDuration(obj) {
3176 return obj instanceof Duration;

Callers

nothing calls this directly

Calls 3

normalizeObjectUnitsFunction · 0.85
isDurationValidFunction · 0.85
getLocaleFunction · 0.85

Tested by

no test coverage detected