Page MenuHomeSealhub

time-units.js
No OneTemporary

time-units.js

function time_units(from, to, amount) {
const formats = {
'h': 3600000,
'm': 60000,
's': 1000,
'ms': 1
}
amount = new Number(amount);
if (!formats[from] || !formats[to]) {
throw new Error('Please provide a valid time format');
}
if (!amount || typeof amount.valueOf() !== 'number') {
throw new Error('Please provide a valid amount to convert');
}
return (formats[from] / formats[to]).toPrecision(8);
}
module.exports = time_units;

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 11, 09:23 (1 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
984113
Default Alt Text
time-units.js (515 B)

Event Timeline