/var/www/greso.tech/server/nsm/node_modules/moment/src/lib/duration
NameSizeModeActions
abs.js4840644editdlrm
add-subtract.js6440644editdlrm
as.js23600644editdlrm
bubble.js17740644editdlrm
clone.js1050644editdlrm
constructor.js15930644editdlrm
create.js43350644editdlrm
duration.js3420644editdlrm
get.js7280644editdlrm
humanize.js34930644editdlrm
iso-string.js20780644editdlrm
prototype.js17390644editdlrm
valid.js11840644editdlrm
Edit: /var/www/greso.tech/server/nsm/node_modules/moment/src/lib/duration/as.js (2360B)
import { daysToMonths, monthsToDays } from './bubble'; import { normalizeUnits } from '../units/aliases'; import toInt from '../utils/to-int'; export function as(units) { if (!this.isValid()) { return NaN; } var days, months, milliseconds = this._milliseconds; units = normalizeUnits(units); if (units === 'month' || units === 'quarter' || units === 'year') { days = this._days + milliseconds / 864e5; months = this._months + daysToMonths(days); switch (units) { case 'month': return months; case 'quarter': return months / 3; case 'year': return months / 12; } } else { // handle milliseconds separately because of floating point math errors (issue #1867) days = this._days + Math.round(monthsToDays(this._months)); switch (units) { case 'week': return days / 7 + milliseconds / 6048e5; case 'day': return days + milliseconds / 864e5; case 'hour': return days * 24 + milliseconds / 36e5; case 'minute': return days * 1440 + milliseconds / 6e4; case 'second': return days * 86400 + milliseconds / 1000; // Math.floor prevents floating point math errors here case 'millisecond': return Math.floor(days * 864e5) + milliseconds; default: throw new Error('Unknown unit ' + units); } } } // TODO: Use this.as('ms')? export function valueOf() { if (!this.isValid()) { return NaN; } return ( this._milliseconds + this._days * 864e5 + (this._months % 12) * 2592e6 + toInt(this._months / 12) * 31536e6 ); } function makeAs(alias) { return function () { return this.as(alias); }; } var asMilliseconds = makeAs('ms'), asSeconds = makeAs('s'), asMinutes = makeAs('m'), asHours = makeAs('h'), asDays = makeAs('d'), asWeeks = makeAs('w'), asMonths = makeAs('M'), asQuarters = makeAs('Q'), asYears = makeAs('y'); export { asMilliseconds, asSeconds, asMinutes, asHours, asDays, asWeeks, asMonths, asQuarters, asYears, };