API
Here's the API documentation for Aezen's duration module.
Duration class
Prop | Type | Default |
---|---|---|
pattern | string | number | - |
fromNow()
Get the date from now based on the provided time.
- Returns the calculated
Date
.
dateFrom()
Get the date from a specified date instance.
- Returns the calculated
Date
.
Prop | Type | Default |
---|---|---|
date | Date | - |
verbose()
Converts a duration to a verbose string.
- Returns the formatted verbose
string
.
Prop | Type | Default |
---|---|---|
precision | number | 7 |
separators | object | DEFAULT_SEPARATORS |
binary() Converts a duration to binary notation.
- Returns a
string
in binary notation.
colon()
Converts a duration to colon notation (HH:mm:ss).
- Returns a
string
in colon notation.
scientific()
Converts a duration to scientific notation.
- Returns a
string
in scientific notation.
compact()
Converts a duration to a compact string with formatted units.
- Returns a
string
in compact format.
Prop | Type | Default |
---|---|---|
options | object | null |
options.separator | string | " " |
elegant()
Converts a duration to an elegant string with formatted units.
- Returns a
string
in elegant format.
Prop | Type | Default |
---|---|---|
precision | number | 7 |
separators | object | DEFAULT_SEPARATORS |
separators.left | string | " " |
separators.right | string | " " |
object()
Converts a duration in BigNumber format into an object representing various time units.
- Throws an
Error
if the duration is not a valid number. - Returns an
object
representing the duration in different time units.
Credits
This module is forked and modified from sapphiredev's module, so credits to the original author. If you have copyright issues, please contact me first.
Last updated on