Skip to main content

Class: Duration

Defined in: Duration.ts:73

Converts duration strings into ms and future dates

Constructors​

Constructor​

new Duration(pattern: string): Duration

Defined in: Duration.ts:133

Create a new Duration instance

Parameters​

ParameterTypeDescription
patternstringThe string to parse

Returns​

Duration

Properties​

days​

days: number = 0

Defined in: Duration.ts:112

The amount of days extracted from the text.


hours​

hours: number = 0

Defined in: Duration.ts:107

The amount of hours extracted from the text.


microseconds​

microseconds: number = 0

Defined in: Duration.ts:87

The amount of microseconds extracted from the text.


milliseconds​

milliseconds: number = 0

Defined in: Duration.ts:92

The amount of milliseconds extracted from the text.


minutes​

minutes: number = 0

Defined in: Duration.ts:102

The amount of minutes extracted from the text.


months​

months: number = 0

Defined in: Duration.ts:122

The amount of months extracted from the text.


nanoseconds​

nanoseconds: number = 0

Defined in: Duration.ts:82

The amount of nanoseconds extracted from the text.


offset​

offset: number

Defined in: Duration.ts:77

The offset


seconds​

seconds: number = 0

Defined in: Duration.ts:97

The amount of seconds extracted from the text.


weeks​

weeks: number = 0

Defined in: Duration.ts:117

The amount of weeks extracted from the text.


years​

years: number = 0

Defined in: Duration.ts:127

The amount of years extracted from the text.


aAndAnRegex​

private readonly static aAndAnRegex: RegExp

Defined in: Duration.ts:186

The RegExp used for replacing a/an with 1


commaRegex​

private readonly static commaRegex: RegExp

Defined in: Duration.ts:181

The RegExp used for removing commas


patternRegex​

private readonly static patternRegex: RegExp

Defined in: Duration.ts:176

The RegExp used for the pattern parsing

Accessors​

fromNow​

Get Signature​

get fromNow(): Date

Defined in: Duration.ts:161

Get the date from now

Returns​

Date

Methods​

dateFrom()​

dateFrom(date: Date): Date

Defined in: Duration.ts:169

Get the date from

Parameters​

ParameterTypeDescription
dateDateThe Date instance to get the date from

Returns​

Date