UtilitiesDurationAPI

API

Here's the API documentation for Aezen's duration module.

Duration class

PropTypeDefault
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.
PropTypeDefault
date
Date
-

verbose()

Converts a duration to a verbose string.

  • Returns the formatted verbose string.
PropTypeDefault
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.
PropTypeDefault
options
object
null
options.separator
string
" "

elegant()

Converts a duration to an elegant string with formatted units.

  • Returns a string in elegant format.
PropTypeDefault
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.
PropTypeDefault
duration
number | bignumber.js
-

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