Show / Hide Table of Contents

Class Duration

Represents a length of time.

The amount can be specified either as a literal value (e.g: 10) which cannot be negative, or as an unresolved number token.

When the amount is passed as a token, unit conversion is not possible.

stable

Synopsis

Methods

days(amount)

Create a Duration representing an amount of days.

hours(amount)

Create a Duration representing an amount of hours.

millis(amount)

Create a Duration representing an amount of milliseconds.

minutes(amount)

Create a Duration representing an amount of minutes.

parse(duration)

Parse a period formatted according to the ISO 8601 standard.

plus(rhs)

Add two Durations together.

seconds(amount)

Create a Duration representing an amount of seconds.

toDays(opts)

Return the total number of days in this Duration.

toHours(opts)

Return the total number of hours in this Duration.

toHumanString()

Turn this duration into a human-readable string.

toIsoString()

Return an ISO 8601 representation of this period.

toISOString()

(deprecated) Return an ISO 8601 representation of this period.

toMilliseconds(opts)

Return the total number of milliseconds in this Duration.

toMinutes(opts)

Return the total number of minutes in this Duration.

toSeconds(opts)

Return the total number of seconds in this Duration.

Methods

days(amount)

Create a Duration representing an amount of days.

Declaration
static days(amount: number): Duration;
Parameters
amount number
Returns

Duration

a new Duration representing amount Days. stable

hours(amount)

Create a Duration representing an amount of hours.

Declaration
static hours(amount: number): Duration;
Parameters
amount number
Returns

Duration

a new Duration representing amount Hours. stable

millis(amount)

Create a Duration representing an amount of milliseconds.

Declaration
static millis(amount: number): Duration;
Parameters
amount number
Returns

Duration

a new Duration representing amount ms. stable

minutes(amount)

Create a Duration representing an amount of minutes.

Declaration
static minutes(amount: number): Duration;
Parameters
amount number
Returns

Duration

a new Duration representing amount Minutes. stable

parse(duration)

Parse a period formatted according to the ISO 8601 standard.

Declaration
static parse(duration: string): Duration;
Parameters
duration string
Returns

Duration

the parsed Duration. https://www.iso.org/fr/standard/70907.html stable

plus(rhs)

Add two Durations together.

stable

Declaration
plus(rhs: Duration): Duration;
Parameters
rhs Duration
Returns

Duration

seconds(amount)

Create a Duration representing an amount of seconds.

Declaration
static seconds(amount: number): Duration;
Parameters
amount number
Returns

Duration

a new Duration representing amount Seconds. stable

toDays(opts)

Return the total number of days in this Duration.

Declaration
toDays(opts?: TimeConversionOptions): number;
Parameters
opts TimeConversionOptions
Returns

number

the value of this Duration expressed in Days. stable

toHours(opts)

Return the total number of hours in this Duration.

Declaration
toHours(opts?: TimeConversionOptions): number;
Parameters
opts TimeConversionOptions
Returns

number

the value of this Duration expressed in Hours. stable

toHumanString()

Turn this duration into a human-readable string.

stable

Declaration
toHumanString(): string;
Returns

string

toIsoString()

Return an ISO 8601 representation of this period.

Declaration
toIsoString(): string;
Returns

string

a string starting with 'P' describing the period https://www.iso.org/fr/standard/70907.html stable

toISOString()

(deprecated) Return an ISO 8601 representation of this period.

Declaration
toISOString(): string;
Returns

string

a string starting with 'P' describing the period https://www.iso.org/fr/standard/70907.html

toMilliseconds(opts)

Return the total number of milliseconds in this Duration.

Declaration
toMilliseconds(opts?: TimeConversionOptions): number;
Parameters
opts TimeConversionOptions
Returns

number

the value of this Duration expressed in Milliseconds. stable

toMinutes(opts)

Return the total number of minutes in this Duration.

Declaration
toMinutes(opts?: TimeConversionOptions): number;
Parameters
opts TimeConversionOptions
Returns

number

the value of this Duration expressed in Minutes. stable

toSeconds(opts)

Return the total number of seconds in this Duration.

Declaration
toSeconds(opts?: TimeConversionOptions): number;
Parameters
opts TimeConversionOptions
Returns

number

the value of this Duration expressed in Seconds. stable

Back to top Generated by DocFX