Conversion
Every converter has the same shape:
interface UnitConverter {
(amount: number): number;
from: (ms: number) => number;
}- Calling it converts an amount of the unit to milliseconds.
.from(ms)converts milliseconds to an amount of the unit.
See Converting units for examples.
weeks
weeks(amount: number): number
weeks.from(ms: number): numberConverts weeks to milliseconds, and .from() converts milliseconds to weeks. One week is 604_800_000 milliseconds.
days
days(amount: number): number
days.from(ms: number): numberConverts days to milliseconds, and .from() converts milliseconds to days. One day is 86_400_000 milliseconds.
hours
hours(amount: number): number
hours.from(ms: number): numberConverts hours to milliseconds, and .from() converts milliseconds to hours. One hour is 3_600_000 milliseconds.
minutes
minutes(amount: number): number
minutes.from(ms: number): numberConverts minutes to milliseconds, and .from() converts milliseconds to minutes. One minute is 60_000 milliseconds.
seconds
seconds(amount: number): number
seconds.from(ms: number): numberConverts seconds to milliseconds, and .from() converts milliseconds to seconds. One second is 1_000 milliseconds.
milliseconds
milliseconds(amount: number): number
milliseconds.from(ms: number): numberReturns its input unchanged, in both directions. It exists so every unit works the same way; see the FAQ.
microseconds
microseconds(amount: number): number
microseconds.from(ms: number): numberConverts microseconds to milliseconds, and .from() converts milliseconds to microseconds. One microsecond is 0.001 milliseconds.
nanoseconds
nanoseconds(amount: number): number
nanoseconds.from(ms: number): numberConverts nanoseconds to milliseconds, and .from() converts milliseconds to nanoseconds. One nanosecond is 0.000_001 milliseconds.