Sha256: f7b74de1000980867f7c7c2901dac26b137fcf0c00f4b53af53d52ebae5937fc

Contents?: true

Size: 950 Bytes

Versions: 19

Compression:

Stored size: 950 Bytes

Contents

import { normalizeUnits } from '../units/aliases';
import { hooks } from '../utils/hooks';

export function makeGetSet (unit, keepTime) {
    return function (value) {
        if (value != null) {
            set(this, unit, value);
            hooks.updateOffset(this, keepTime);
            return this;
        } else {
            return get(this, unit);
        }
    };
}

export function get (mom, unit) {
    return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
}

export function set (mom, unit, value) {
    return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
}

// MOMENTS

export function getSet (units, value) {
    var unit;
    if (typeof units === 'object') {
        for (unit in units) {
            this.set(unit, units[unit]);
        }
    } else {
        units = normalizeUnits(units);
        if (typeof this[units] === 'function') {
            return this[units](value);
        }
    }
    return this;
}

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
active_record_survey_api-0.0.19 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.18 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.17 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.14 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.12 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.11 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.7 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
active_record_survey_api-0.0.6 spec/test_app/vendor/assets/bower_components/moment/src/lib/moment/get-set.js
date_picker-0.0.8 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.7 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
sedge_cms-0.0.1 vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.6 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.5 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.4 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.3 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.2 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
date_picker-0.0.1 test/dummy/vendor/assets/components/moment/src/lib/moment/get-set.js
puppet-herald-0.8.1 lib/puppet-herald/public/bower_components/moment/src/lib/moment/get-set.js
puppet-herald-0.8.0 lib/puppet-herald/public/bower_components/moment/src/lib/moment/get-set.js