Class Duration

Hierarchy

  • Duration

Constructors

  • Construct a new duration from a parameter object representing the duration unit values.

    Parameters

    • params: Partial<DurationValues>

      See DurationValues type for valid fields. All fields optional.

    Returns Duration

Methods

  • Return a Duration constructed from the provided count and DurationUnit

    Parameters

    • count: number

      The number of units the duration should represent

    • unit: keyof DurationValues

      The time unit to create this duration from e.g. 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'

    Returns Duration

    A new Duration

  • Return a Duration parsed from a space separated string in the format "{{count}} {{unit}}" e.g. 30 seconds, 5 minutes, 2 days

    Parameters

    • parseable: string

      The string to parse

    Returns Duration

    A new Duration

  • Return the duration value converted to the target unit

    Parameters

    Returns number

    The numerical value of this duration in the specified unit

  • Converts this duration to an integer of the target unit. Remainder values will be truncated.

    Parameters

    Returns number

    The truncated integer value of the duration converted to the target unit

  • Represents this duration as a values object where the length of the duration is distributed across the various units from largest to smallest

    Returns DurationValues

    DurationValues

  • Represents this duration as a values object where each value represents the total integer size of the duration expressed as that unit.

    Returns Readonly<DurationValues>

    DurationTotals

  • Parameters

    • other: Duration

      Duration

    • Optional orEqual: boolean

      optional

    Returns boolean

    boolean

  • Parameters

    • other: Duration

      Duration

    • Optional orEqual: boolean

      optional

    Returns boolean

    boolean

Generated using TypeDoc