Skip to content

Commit

Permalink
chore: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Dec 12, 2024
1 parent 63f7e39 commit d3f1d8b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dates/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,16 @@ export const getFullRelativeTime = (date: DateTime): string => `${getDateHourMin
*
* @param {number} duration - the duration in milliseconds
* @returns {string} the formatted duration (e.g. `1m 39s`)
*
* @example
* ```ts
* import { formatDuration } from 'jsr:@frytg/dates'
*
* formatDuration(1000) // 1s
*
* const startTs = getMs()
* // do something...
* formatDuration(getMsOffset(startTs)) // time taken
* ```
*/
export const formatDuration = (duration: number) => stdFormat(duration, { ignoreZero: true })

0 comments on commit d3f1d8b

Please sign in to comment.