@panyam/tsutils
Version:
Some basic TS utils for personal use
35 lines • 855 B
JavaScript
export const ONE_MUS = 1000;
export const ONE_MS = 1000000;
export const ONE_SEC = 1000000000;
export const ONE_MIN = 60000000000;
export const ONE_HOUR = 3600000000000;
export function Hours(val) {
return ONE_HOUR * val;
}
export function Minutes(val) {
return ONE_MIN * val;
}
export function Seconds(val) {
return ONE_SEC * val;
}
export function Micros(val) {
return ONE_MUS * val;
}
export function Millis(val) {
return ONE_MS * val;
}
export function StrToDuration(value) {
value = value.toLowerCase();
const intValue = parseInt(value);
if (value.endsWith("ms")) {
return Millis(intValue);
}
else if (value.endsWith("mus")) {
return Micros(intValue);
}
else if (value.endsWith("s")) {
return Seconds(intValue);
}
return intValue;
}
//# sourceMappingURL=timeutils.js.map