css-duration
Converts CSS-style durations to milliseconds.
var duration = // > 1000 // > 1500 // > 1800000 // > 28800000 // > 172800000
Installation
npm install --save css-duration
Usage
duration(time)
Normalizes "unit-based time" (similar to CSS values) into a Number
of milliseconds.
Parameters
time
(String
): A CSS-style value of a duration of time (i.e.10s
,5h
,0.5d
)
Units
ms
: Millisecondss
: Secondsh
: Hoursd
: Daysw
: Weeks
Note: Anything past seconds is not a valid CSS unit. Use another package for validating.
Example
// => 21600000 // => -604800000
License
MIT © Brandon Semilla