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.ts:133

Properties​

days​

days: number = 0

The amount of days extracted from the text.

Defined in​

Duration.ts:112


hours​

hours: number = 0

The amount of hours extracted from the text.

Defined in​

Duration.ts:107


microseconds​

microseconds: number = 0

The amount of microseconds extracted from the text.

Defined in​

Duration.ts:87


milliseconds​

milliseconds: number = 0

The amount of milliseconds extracted from the text.

Defined in​

Duration.ts:92


minutes​

minutes: number = 0

The amount of minutes extracted from the text.

Defined in​

Duration.ts:102


months​

months: number = 0

The amount of months extracted from the text.

Defined in​

Duration.ts:122


nanoseconds​

nanoseconds: number = 0

The amount of nanoseconds extracted from the text.

Defined in​

Duration.ts:82


offset​

offset: number

The offset

Defined in​

Duration.ts:77


seconds​

seconds: number = 0

The amount of seconds extracted from the text.

Defined in​

Duration.ts:97


weeks​

weeks: number = 0

The amount of weeks extracted from the text.

Defined in​

Duration.ts:117


years​

years: number = 0

The amount of years extracted from the text.

Defined in​

Duration.ts:127


aAndAnRegex​

private readonly static aAndAnRegex: RegExp

The RegExp used for replacing a/an with 1

Defined in​

Duration.ts:186


commaRegex​

private readonly static commaRegex: RegExp

The RegExp used for removing commas

Defined in​

Duration.ts:181


patternRegex​

private readonly static patternRegex: RegExp

The RegExp used for the pattern parsing

Defined in​

Duration.ts:176

Accessors​

fromNow​

Get Signature​

get fromNow(): Date

Get the date from now

Returns​

Date

Defined in​

Duration.ts:161

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.ts:169