Sha256: d601c619a8cf86505b125284b6ba34e8952038a7a9eeea204d05366226583a3b

Contents?: true

Size: 1.34 KB

Versions: 25

Compression:

Stored size: 1.34 KB

Contents

import { normalizeObjectUnits } from '../units/aliases';
import { getLocale } from '../locale/locales';

export function Duration (duration) {
    var normalizedInput = normalizeObjectUnits(duration),
        years = normalizedInput.year || 0,
        quarters = normalizedInput.quarter || 0,
        months = normalizedInput.month || 0,
        weeks = normalizedInput.week || 0,
        days = normalizedInput.day || 0,
        hours = normalizedInput.hour || 0,
        minutes = normalizedInput.minute || 0,
        seconds = normalizedInput.second || 0,
        milliseconds = normalizedInput.millisecond || 0;

    // representation for dateAddRemove
    this._milliseconds = +milliseconds +
        seconds * 1e3 + // 1000
        minutes * 6e4 + // 1000 * 60
        hours * 36e5; // 1000 * 60 * 60
    // Because of dateAddRemove treats 24 hours as different from a
    // day when working around DST, we need to store them separately
    this._days = +days +
        weeks * 7;
    // It is impossible translate months into days without knowing
    // which months you are are talking about, so we have to store
    // it separately.
    this._months = +months +
        quarters * 3 +
        years * 12;

    this._data = {};

    this._locale = getLocale();

    this._bubble();
}

export function isDuration (obj) {
    return obj instanceof Duration;
}

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
active_record_survey_api-0.0.19 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.18 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.17 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.14 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.12 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
locomotivecms-3.2.0.rc1 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
locomotivecms-3.1.1 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
locomotivecms-3.1.0 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.11 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
locomotivecms-3.1.0.rc3 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
locomotivecms-3.1.0.rc2 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
locomotivecms-3.1.0.rc1 vendor/assets/components/locomotive_sources/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.7 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
active_record_survey_api-0.0.6 spec/test_app/vendor/assets/bower_components/moment/src/lib/duration/constructor.js
date_picker-0.0.8 test/dummy/vendor/assets/components/moment/src/lib/duration/constructor.js
date_picker-0.0.7 test/dummy/vendor/assets/components/moment/src/lib/duration/constructor.js
sedge_cms-0.0.1 vendor/assets/components/moment/src/lib/duration/constructor.js
date_picker-0.0.6 test/dummy/vendor/assets/components/moment/src/lib/duration/constructor.js
date_picker-0.0.5 test/dummy/vendor/assets/components/moment/src/lib/duration/constructor.js
date_picker-0.0.4 test/dummy/vendor/assets/components/moment/src/lib/duration/constructor.js