Skip to main content

Class: Duration

Converts duration strings into ms and future dates

Constructors

new Duration()

new Duration(pattern: string): Duration

Create a new Duration instance

Parameters

ParameterTypeDescription
patternstringThe string to parse

Returns

Duration

Defined in

duration/dist/esm/index.d.mts:107

Properties

days

days: number

The amount of days extracted from the text.

Defined in

duration/dist/esm/index.d.mts:90


hours

hours: number

The amount of hours extracted from the text.

Defined in

duration/dist/esm/index.d.mts:86


microseconds

microseconds: number

The amount of microseconds extracted from the text.

Defined in

duration/dist/esm/index.d.mts:70


milliseconds

milliseconds: number

The amount of milliseconds extracted from the text.

Defined in

duration/dist/esm/index.d.mts:74


minutes

minutes: number

The amount of minutes extracted from the text.

Defined in

duration/dist/esm/index.d.mts:82


months

months: number

The amount of months extracted from the text.

Defined in

duration/dist/esm/index.d.mts:98


nanoseconds

nanoseconds: number

The amount of nanoseconds extracted from the text.

Defined in

duration/dist/esm/index.d.mts:66


offset

offset: number

The offset

Defined in

duration/dist/esm/index.d.mts:62


seconds

seconds: number

The amount of seconds extracted from the text.

Defined in

duration/dist/esm/index.d.mts:78


weeks

weeks: number

The amount of weeks extracted from the text.

Defined in

duration/dist/esm/index.d.mts:94


years

years: number

The amount of years extracted from the text.

Defined in

duration/dist/esm/index.d.mts:102

Accessors

fromNow

get fromNow(): Date

Get the date from now

Returns

Date

Defined in

duration/dist/esm/index.d.mts:111

Methods

dateFrom()

dateFrom(date: Date): Date

Get the date from

Parameters

ParameterTypeDescription
dateDateThe Date instance to get the date from

Returns

Date

Defined in

duration/dist/esm/index.d.mts:116