corrade-nucleus-nucleons – Blame information for rev 38

Subversion Repositories:
Rev:
Rev Author Line No. Line
38 office 1 import { normalizeObjectUnits } from '../units/aliases';
2 import { getLocale } from '../locale/locales';
3 import isDurationValid from './valid.js';
4  
5 export function Duration (duration) {
6 var normalizedInput = normalizeObjectUnits(duration),
7 years = normalizedInput.year || 0,
8 quarters = normalizedInput.quarter || 0,
9 months = normalizedInput.month || 0,
10 weeks = normalizedInput.week || 0,
11 days = normalizedInput.day || 0,
12 hours = normalizedInput.hour || 0,
13 minutes = normalizedInput.minute || 0,
14 seconds = normalizedInput.second || 0,
15 milliseconds = normalizedInput.millisecond || 0;
16  
17 this._isValid = isDurationValid(normalizedInput);
18  
19 // representation for dateAddRemove
20 this._milliseconds = +milliseconds +
21 seconds * 1e3 + // 1000
22 minutes * 6e4 + // 1000 * 60
23 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
24 // Because of dateAddRemove treats 24 hours as different from a
25 // day when working around DST, we need to store them separately
26 this._days = +days +
27 weeks * 7;
28 // It is impossible translate months into days without knowing
29 // which months you are are talking about, so we have to store
30 // it separately.
31 this._months = +months +
32 quarters * 3 +
33 years * 12;
34  
35 this._data = {};
36  
37 this._locale = getLocale();
38  
39 this._bubble();
40 }
41  
42 export function isDuration (obj) {
43 return obj instanceof Duration;
44 }