The TimeSpan class is used for representing time interval. TimeSpan class cannot be negative, if you pass negative number it will be converted to 0.

IMPORT_PATH: "@daiso-tech/core/time-span"

Implements

Methods

  • Checks if this value equals the given value. Implementation defines what "equal" means for this type.

    Parameters

    • value: ITimeSpan

      The value to compare against

    Returns boolean

    True if values are equal, false otherwise

  • Serializes this instance to a versioned format. Instance method that converts the current state to a storable/transportable form. Must include a version field for deserialization to know how to reconstruct.

    Returns SerializedTimeSpan

    Serialized representation with version field

  • Create a TimeSpan from string

    Parameters

    • timeAsStr: string

    Returns TimeSpan

    // Will be 5000 milliseconds.
    TimeSpan.fromStr("5s").toMilliseconds()

    Under the hood, this method leverages @lukeed/ms package to convert various time formats into milliseconds. Refer to its documentation for a complete list of supported time formats and units.