Skip to main content

Class: Duration

@sapphire/time-utilities.Duration

Converts duration strings into ms and future dates

Constructors

constructor

new Duration(pattern)

Create a new Duration instance

Parameters

NameTypeDescription
patternstringThe string to parse

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:107

Properties

days

days: number

The amount of days extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:90


hours

hours: number

The amount of hours extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:86


microseconds

microseconds: number

The amount of microseconds extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:70


milliseconds

milliseconds: number

The amount of milliseconds extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:74


minutes

minutes: number

The amount of minutes extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:82


months

months: number

The amount of months extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:98


nanoseconds

nanoseconds: number

The amount of nanoseconds extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:66


offset

offset: number

The offset

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:62


seconds

seconds: number

The amount of seconds extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:78


weeks

weeks: number

The amount of weeks extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:94


years

years: number

The amount of years extracted from the text.

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:102


aAndAnRegex

Private Static Readonly aAndAnRegex: any

The RegExp used for replacing a/an with 1

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:128


commaRegex

Private Static Readonly commaRegex: any

The RegExp used for removing commas

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:124


patternRegex

Private Static Readonly patternRegex: any

The RegExp used for the pattern parsing

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:120

Accessors

fromNow

get fromNow(): Date

Get the date from now

Returns

Date

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:111

Methods

dateFrom

dateFrom(date): Date

Get the date from

Parameters

NameTypeDescription
dateDateThe Date instance to get the date from

Returns

Date

Defined in

node_modules/@sapphire/duration/dist/index.d.ts:116