Class: Duration
@sapphire/duration.Duration
Converts duration strings into ms and future dates
Constructors
constructor
• new Duration(pattern
)
Create a new Duration instance
Parameters
Name | Type | Description |
---|---|---|
pattern | string | The string to parse |
Defined in
Properties
days
• days: number
= 0
The amount of days extracted from the text.
Defined in
hours
• hours: number
= 0
The amount of hours extracted from the text.
Defined in
microseconds
• microseconds: number
= 0
The amount of microseconds extracted from the text.
Defined in
milliseconds
• milliseconds: number
= 0
The amount of milliseconds extracted from the text.
Defined in
minutes
• minutes: number
= 0
The amount of minutes extracted from the text.
Defined in
months
• months: number
= 0
The amount of months extracted from the text.
Defined in
nanoseconds
• nanoseconds: number
= 0
The amount of nanoseconds extracted from the text.
Defined in
offset
• offset: number
The offset
Defined in
seconds
• seconds: number
= 0
The amount of seconds extracted from the text.
Defined in
weeks
• weeks: number
= 0
The amount of weeks extracted from the text.
Defined in
years
• years: number
= 0
The amount of years extracted from the text.
Defined in
aAndAnRegex
▪ Private
Static
Readonly
aAndAnRegex: RegExp
The RegExp used for replacing a/an with 1
Defined in
commaRegex
▪ Private
Static
Readonly
commaRegex: RegExp
The RegExp used for removing commas
Defined in
patternRegex
▪ Private
Static
Readonly
patternRegex: RegExp
The RegExp used for the pattern parsing
Defined in
Accessors
fromNow
• get
fromNow(): Date
Get the date from now
Returns
Defined in
Methods
dateFrom
▸ dateFrom(date
): Date
Get the date from
Parameters
Name | Type | Description |
---|---|---|
date | Date | The Date instance to get the date from |