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

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:107

Properties

days

days: number

The amount of days extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:90


hours

hours: number

The amount of hours extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:86


microseconds

microseconds: number

The amount of microseconds extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:70


milliseconds

milliseconds: number

The amount of milliseconds extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:74


minutes

minutes: number

The amount of minutes extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:82


months

months: number

The amount of months extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:98


nanoseconds

nanoseconds: number

The amount of nanoseconds extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:66


offset

offset: number

The offset

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:62


seconds

seconds: number

The amount of seconds extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:78


weeks

weeks: number

The amount of weeks extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:94


years

years: number

The amount of years extracted from the text.

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:102


aAndAnRegex

private static readonly aAndAnRegex: any

The RegExp used for replacing a/an with 1

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:128


commaRegex

private static readonly commaRegex: any

The RegExp used for removing commas

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:124


patternRegex

private static readonly patternRegex: any

The RegExp used for the pattern parsing

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:120

Accessors

fromNow

get fromNow(): Date

Get the date from now

Returns

Date

Source

node_modules/@sapphire/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

Source

node_modules/@sapphire/duration/dist/esm/index.d.mts:116