The type has the following constructor:

const duration = new  Duration(100, 'millisecond');

The second constructor parameter is a measurement unit with the following values:

  • milliseconds
  • seconds
  • minutes
  • hours
  • days If the measurement unit is not specified,
    the default one is milliseconds.
    const duration = new  Duration(100); // 100 milliseconds 
    
    This type is immutable, so mutation methods return the updated value without changing the original one.
    const hour = new Duration(1, 'hours');
    const day = hour.add(new  Duration(23, 'hours')); 
    
module

Types

Hierarchy

  • TDuration

Properties

Readonly days

days: number

Days.

Readonly hours

hours: number

Hours.

Readonly milliseconds

milliseconds: number

Milliseconds.

Readonly minutes

minutes: number

Minutes.

Readonly seconds

seconds: number

Seconds.

Methods

add

  • Add up the durations.

    Parameters

    Returns TDuration