@studiokeywi/banjo - v0.0.1
    Preparing search index...

    Interface Chrono<Unit, Value>

    A Chrono object blends human-friendly strings with known values and pre-calculated conversions to make working with multi-resolution durations easier

    interface Chrono<Unit extends Units = Units, Value extends number = number> {
        days: Unit extends "days" ? Value : number;
        hours: Unit extends "hours" ? Value : number;
        milliseconds: Unit extends "milliseconds" ? Value : number;
        minutes: Unit extends "minutes" ? Value : number;
        seconds: Unit extends "seconds" ? Value : number;
        as<As extends Units>(as: As): Chrono<As>;
        toString(): `${Value} ${Unit}`;
        valueOf(): Value;
    }

    Type Parameters

    • Unit extends Units = Units
    • Value extends number = number
    Index

    Properties

    days: Unit extends "days" ? Value : number

    The equivalent duration of this Chrono object in days

    hours: Unit extends "hours" ? Value : number

    The equivalent duration of this Chrono object in hours

    milliseconds: Unit extends "milliseconds" ? Value : number

    The equivalent duration of this Chrono object in milliseconds

    minutes: Unit extends "minutes" ? Value : number

    The equivalent duration of this Chrono object in minutes

    seconds: Unit extends "seconds" ? Value : number

    The equivalent duration of this Chrono object in seconds

    Methods

    • Casts this Chrono object into a new base unit. Note that downwards conversions (eg hours -> seconds) can lose precision from floating point errors. Additionally, for TypeScript, conversions lose the Value type specificity.

      Type Parameters

      Parameters

      Returns Chrono<As>