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

projects/utilities/packages/time-utilities/src/lib/Duration.ts:64

Properties

offset

โ€ข offset: number

The offset

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:58


kAanRegex

โ–ช Static Private Readonly kAanRegex: RegExp

The RegExp used for replacing a/an with 1

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:96


kCommaRegex

โ–ช Static Private Readonly kCommaRegex: RegExp

The RegExp used for removing commas

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:91


kPatternRegex

โ–ช Static Private Readonly kPatternRegex: RegExp

The RegExp used for the pattern parsing

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:86

Accessors

fromNow

โ€ข get fromNow(): Date

Get the date from now

Returns

Date

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:71

Methods

dateFrom

โ–ธ dateFrom(date): Date

Get the date from

Parameters

NameTypeDescription
dateDateThe Date instance to get the date from

Returns

Date

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:79


parse

โ–ธ Static Private parse(pattern): number

Parse the pattern

Parameters

NameTypeDescription
patternstringThe pattern to parse

Returns

number

Defined in

projects/utilities/packages/time-utilities/src/lib/Duration.ts:102