Skip to main content

@std/fmt@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score58%
Published2 years ago (0.215.0)

Format milliseconds to time duration.

import { format } from "@std/fmt/duration";

// "00:00:01:39:674:000:000"
format(99674, { style: "digital" });

// "0d 0h 1m 39s 674ms 0µs 0ns"
format(99674);

// "1m 39s 674ms"
format(99674, { ignoreZero: true });

// "1 minutes, 39 seconds, 674 milliseconds"
format(99674, { style: "full", ignoreZero: true });

Functions

f
format(
ms: number,
options?: Partial<PrettyDurationOptions>
): string

Format milliseconds to time duration.

Interfaces

  • ignoreZero: boolean

    Whether to ignore zero values. With style="narrow" | "full", all zero values are ignored. With style="digital", only values in the ends are ignored.

  • style: "narrow" | "digital" | "full"

    "narrow" for "0d 0h 0m 0s 0ms..." "digital" for "00:00:00:00:000..." "full" for "0 days, 0 hours, 0 minutes,..."

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/fmt

Import symbol

import * as mod from "@std/fmt/duration";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/fmt/duration";