UNPKG

@toreda/time

Version:

Simple, small footprint library for common time operations and converting between units of time.

25 lines (24 loc) 986 B
import type { LogLike } from '../log/like'; import type { Time } from '../time'; import type { TimeUnit } from './unit'; /** * Create a new Time instance with the provided unit type and initial value. Wraps an * internal data instance only available in factory function closure. * * Bad input is sanitized rather than rejected: an unsupported `units` value * falls back to `'s'` and a non-finite, out-of-safe-range, or unparseable * `initial` falls back to `0`. In both cases the substitution is logged via * the `log` arg (or a default log if none is supplied) and construction * still succeeds. * * `initial` accepts a number or any duration string supported by * `timeValueParse` (e.g. '5', '1.5h', '1h30m'). Date strings should be * parsed via `timeValueParseDate` / `timeFromDate` instead. * * @param units * @param initial * @param log * * @category Factories */ export declare function timeMake(units: TimeUnit, initial: number | string, log?: LogLike): Time;