Debian Codegraph @

vendor/static/moment/src/lib/duration/get.js

raw
1 import { normalizeUnits } from '../units/aliases';
2 import absFloor from '../utils/abs-floor';
3
4 export function get(units) {
5 units = normalizeUnits(units);
6 return this.isValid() ? this[units + 's']() : NaN;
7 }
8
9 function makeGetter(name) {
10 return function () {
11 return this.isValid() ? this._data[name] : NaN;
12 };
13 }
14
15 var milliseconds = makeGetter('milliseconds'),
16 seconds = makeGetter('seconds'),
17 minutes = makeGetter('minutes'),
18 hours = makeGetter('hours'),
19 days = makeGetter('days'),
20 months = makeGetter('months'),
21 years = makeGetter('years');
22
23 export { milliseconds, seconds, minutes, hours, days, months, years };
24
25 export function weeks() {
26 return absFloor(this.days() / 7);
27 }