Skip to main content

Class: Duration

Defined in: duration/dist/esm/index.d.mts:59

Converts duration strings into ms and future dates

Constructors​

Constructor​

new Duration(pattern: string): Duration

Defined in: duration/dist/esm/index.d.mts:108

Create a new Duration instance

Parameters​

ParameterTypeDescription
patternstringThe string to parse

Returns​

Duration

Properties​

days​

days: number

Defined in: duration/dist/esm/index.d.mts:91

The amount of days extracted from the text.


hours​

hours: number

Defined in: duration/dist/esm/index.d.mts:87

The amount of hours extracted from the text.


microseconds​

microseconds: number

Defined in: duration/dist/esm/index.d.mts:71

The amount of microseconds extracted from the text.


milliseconds​

milliseconds: number

Defined in: duration/dist/esm/index.d.mts:75

The amount of milliseconds extracted from the text.


minutes​

minutes: number

Defined in: duration/dist/esm/index.d.mts:83

The amount of minutes extracted from the text.


months​

months: number

Defined in: duration/dist/esm/index.d.mts:99

The amount of months extracted from the text.


nanoseconds​

nanoseconds: number

Defined in: duration/dist/esm/index.d.mts:67

The amount of nanoseconds extracted from the text.


offset​

offset: number

Defined in: duration/dist/esm/index.d.mts:63

The offset


seconds​

seconds: number

Defined in: duration/dist/esm/index.d.mts:79

The amount of seconds extracted from the text.


weeks​

weeks: number

Defined in: duration/dist/esm/index.d.mts:95

The amount of weeks extracted from the text.


years​

years: number

Defined in: duration/dist/esm/index.d.mts:103

The amount of years extracted from the text.


aAndAnRegex​

private readonly static aAndAnRegex: any

Defined in: duration/dist/esm/index.d.mts:129

The RegExp used for replacing a/an with 1


commaRegex​

private readonly static commaRegex: any

Defined in: duration/dist/esm/index.d.mts:125

The RegExp used for removing commas


patternRegex​

private readonly static patternRegex: any

Defined in: duration/dist/esm/index.d.mts:121

The RegExp used for the pattern parsing

Accessors​

fromNow​

Get Signature​

get fromNow(): Date

Defined in: duration/dist/esm/index.d.mts:112

Get the date from now

Returns​

Date

Methods​

dateFrom()​

dateFrom(date: Date): Date

Defined in: duration/dist/esm/index.d.mts:117

Get the date from

Parameters​

ParameterTypeDescription
dateDateThe Date instance to get the date from

Returns​

Date