Skip to main content

Class: Duration

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

Converts duration strings into ms and future dates

Constructors

new Duration()

new Duration(pattern: string): Duration

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

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:90

The amount of days extracted from the text.


hours

hours: number

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

The amount of hours extracted from the text.


microseconds

microseconds: number

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

The amount of microseconds extracted from the text.


milliseconds

milliseconds: number

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

The amount of milliseconds extracted from the text.


minutes

minutes: number

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

The amount of minutes extracted from the text.


months

months: number

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

The amount of months extracted from the text.


nanoseconds

nanoseconds: number

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

The amount of nanoseconds extracted from the text.


offset

offset: number

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

The offset


seconds

seconds: number

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

The amount of seconds extracted from the text.


weeks

weeks: number

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

The amount of weeks extracted from the text.


years

years: number

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

The amount of years extracted from the text.


aAndAnRegex

private readonly static aAndAnRegex: any

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

The RegExp used for replacing a/an with 1


commaRegex

private readonly static commaRegex: any

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

The RegExp used for removing commas


patternRegex

private readonly static patternRegex: any

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

The RegExp used for the pattern parsing

Accessors

fromNow

Get Signature

get fromNow(): Date

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

Get the date from now

Returns

Date

Methods

dateFrom()

dateFrom(date: Date): Date

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

Get the date from

Parameters

ParameterTypeDescription
dateDateThe Date instance to get the date from

Returns

Date