convert a human readable duration to ms
npm install parse-duration-clickup
then in your app:
varparse=require("parse-duration-clickup");convert str to ms
varns=parse("1ns");// => 1 / 1e6varμs=parse("1μs");// => 1 / 1000varms=parse("1ms");// => 1vars=parse("1s");// => ms * 1000varm=parse("1m");// => s * 60varh=parse("1h");// => m * 60vard=parse("1d");// => h * 24varw=parse("1w");// => d * 7vary=parse("1y");// => d * 365.25It can also handle basic compound expressions
parse("1hr 20mins");// => 1 * h + 20 * mwhitespace
parse("1 hr 20 mins");// => 1 * h + 20 * mcomma seperated numbers
parse("27,681 ns");// => 27681 * nsAnd most other types of noise
parse("running length: 1hour:20mins");// => 1* h + 20 * mYou can even use negatives
parse("2hr -40mins");// => 1 * h + 20 * mAnd exponents
parse("2e3s");// => 2000 * sAvailable unit types are:
- nanoseconds (ns)
- microseconds (μs)
- milliseconds (ms)
- seconds (s, sec)
- minutes (m, min)
- hours (h, hr)
- days (d)
- weeks (w, wk)
- months
- years (y, yr)
And its easy to add more