Brought in another asset for Ray's eye form: moment
[openemr.git] / public / assets / moment-2-13-0 / src / lib / duration / constructor.js
blobfb01c7041375a208f10d50007037751e89c298d3
1 import { normalizeObjectUnits } from '../units/aliases';
2 import { getLocale } from '../locale/locales';
4 export function Duration (duration) {
5     var normalizedInput = normalizeObjectUnits(duration),
6         years = normalizedInput.year || 0,
7         quarters = normalizedInput.quarter || 0,
8         months = normalizedInput.month || 0,
9         weeks = normalizedInput.week || 0,
10         days = normalizedInput.day || 0,
11         hours = normalizedInput.hour || 0,
12         minutes = normalizedInput.minute || 0,
13         seconds = normalizedInput.second || 0,
14         milliseconds = normalizedInput.millisecond || 0;
16     // representation for dateAddRemove
17     this._milliseconds = +milliseconds +
18         seconds * 1e3 + // 1000
19         minutes * 6e4 + // 1000 * 60
20         hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
21     // Because of dateAddRemove treats 24 hours as different from a
22     // day when working around DST, we need to store them separately
23     this._days = +days +
24         weeks * 7;
25     // It is impossible translate months into days without knowing
26     // which months you are are talking about, so we have to store
27     // it separately.
28     this._months = +months +
29         quarters * 3 +
30         years * 12;
32     this._data = {};
34     this._locale = getLocale();
36     this._bubble();
39 export function isDuration (obj) {
40     return obj instanceof Duration;