Represents a time of day or a duration. Precision is from hours to miliseconds.

Hierarchy

  • Time

Constructors

  • Creates a new Time instance.

    Parameters

    • input: string | number | number[]

      The time in millisecond representation, or a string in the format "HH:MM:SS.mmm", or an array in the format [HH, MM, SS, mmm].

    Returns Time

    Throws

    if the time is invalid.

Properties

ms: number

The time in millisecond representation. This is the only value stored internally.

Accessors

  • get milliseconds(): number
  • Returns the milliseconds.

    Returns number

  • set milliseconds(value): void
  • Set the milliseconds to a specified value.

    Parameters

    • value: number

      The value to set the milliseconds to.

    Returns void

    Throws

    if the value is invalid.

Methods

  • Adds the specified amount of hours to the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • hours: number

      The amount of hours to add.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Adds the specified amount of milliseconds to the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • milliseconds: number

      The amount of milliseconds to add.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Adds the specified amount of minutes to the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • minutes: number

      The amount of minutes to add.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Adds the specified amount of seconds to the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • seconds: number

      The amount of seconds to add.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Compares this instance to another by comparing millisecond representations.

    Parameters

    • other: Time

      The other Time instance to compare to.

    Returns number

    See

    difference for getting the difference as a new Time instance.

  • Returns a new Time instance that represents the time difference between this instance and another.

    Parameters

    • other: Time

      The other Time instance to compare to.

    Returns Time

    See

    compareTo for getting the difference in milliseconds.

  • Subtracts the specified amount of hours from the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • hours: number

      The amount of hours to subtract.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Subtracts the specified amount of milliseconds from the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • milliseconds: number

      The amount of milliseconds to subtract.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Subtracts the specified amount of minutes from the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • minutes: number

      The amount of minutes to subtract.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Subtracts the specified amount of seconds from the current time. Floating point numbers, neative values and otherwise out of bounds values are allowed unless they would cause the time to become invalid.

    Parameters

    • seconds: number

      The amount of seconds to subtract.

    Returns Time

    Throws

    if the time becomes invalid after the operation.

  • Returns the time as a string in the format "HH:MM:SS.mmm".

    Parameters

    • msDelimiter: string = '.'

      The delimiter between seconds and milliseconds.

    Returns string

Generated using TypeDoc