smarttime/dist/smarttime.units.js

48 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

2017-08-16 14:24:56 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.units = {
years: (timesArg = 1) => {
2018-03-11 15:44:32 +00:00
return timesArg * 3.154e10;
2017-08-16 14:24:56 +00:00
},
months: (timesArg = 1) => {
2018-03-11 15:44:32 +00:00
return timesArg * 2.628e9;
2017-08-16 14:24:56 +00:00
},
weeks: (timesArg = 1) => {
2018-03-11 15:44:32 +00:00
return timesArg * 6.048e8;
2017-08-16 14:24:56 +00:00
},
days: (timesArg = 1) => {
2018-03-11 15:44:32 +00:00
return timesArg * 8.64e7;
2017-08-16 14:24:56 +00:00
},
hours: (timesArg = 1) => {
2018-03-11 15:44:32 +00:00
return timesArg * 3.6e6;
2017-08-16 14:24:56 +00:00
},
minutes: (timesArg = 1) => {
return timesArg * 60000;
}
};
exports.getMilliSecondsFromUnits = (combinationArg) => {
let timeInMilliseconds = 0;
2018-03-11 15:44:32 +00:00
let addMilliSeconds = milliSecondsArg => {
2017-08-16 14:24:56 +00:00
timeInMilliseconds = timeInMilliseconds + milliSecondsArg;
};
if (combinationArg.years) {
addMilliSeconds(exports.units.years(combinationArg.years));
}
if (combinationArg.months) {
addMilliSeconds(exports.units.months(combinationArg.months));
}
if (combinationArg.weeks) {
addMilliSeconds(exports.units.weeks(combinationArg.weeks));
}
if (combinationArg.days) {
addMilliSeconds(exports.units.days(combinationArg.days));
}
if (combinationArg.hours) {
addMilliSeconds(exports.units.hours(combinationArg.hours));
}
if (combinationArg.minutes) {
addMilliSeconds(exports.units.minutes(combinationArg.minutes));
}
return timeInMilliseconds;
};
2018-03-11 15:44:32 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLnVuaXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR0aW1lLnVuaXRzLnRzIl0sIm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