A simple utility class for converting durations between minutes, seconds, and milliseconds.

Constructors

Properties

quantity: number
unit: Unit
DAYS_IN_WEEK: number = 7

The number of days in one week.

HOURS_IN_DAY: number = 24

The number of hours in one day.

MILLIS_IN_SECONDS: number = 1000

The number of milliseconds in one second.

MINUTES_IN_HOUR: number = 60

The number of minutes in one hour.

SECONDS_IN_MINUTE: number = 60

The number of seconds in one minute.

Accessors

  • get days(): number
  • Returns the current number of days represented by this Duration instance.

    Returns number

  • get hours(): number
  • Returns the current number of hours represented by this Duration instance.

    Returns number

  • get milliseconds(): number
  • Returns the current number of milliseconds represented by this Duration instance.

    Returns number

  • get minutes(): number
  • Returns the current number of minutes represented by this Duration instance, rounded to the nearest integer value.

    Returns number

  • get seconds(): number
  • Returns the current number of seconds represented by this Duration instance, rounded to the nearest integer value.

    Returns number

  • get weeks(): number
  • Returns the current number of weeks represented by this Duration instance.

    Returns number

Methods

  • The string representation of this Duration. e.g. "645 seconds"

    Returns string

  • Returns a new Duration instance created from the specified number of days.

    Parameters

    • quantity: number

      The number of days.

    Returns Duration

  • Returns a new Duration instance created from the specified number of hours.

    Parameters

    • quantity: number

      The number of hours.

    Returns Duration

  • Returns a new Duration instance created from the specified number of milliseconds.

    Parameters

    • quantity: number

      The number of milliseconds.

    Returns Duration

  • Returns a new Duration instance created from the specified number of minutes.

    Parameters

    • quantity: number

      The number of minutes.

    Returns Duration

  • Returns a new Duration instance created from the specified number of seconds.

    Parameters

    • quantity: number

      The number of seconds.

    Returns Duration

  • Returns a new Duration instance created from the specified number of weeks.

    Parameters

    • quantity: number

      The number of weeks.

    Returns Duration