Back to Explore

sindresorhus/pretty-ms

GitHub
1 watchersOpen source

Last release:

pretty-ms is a JavaScript utility that converts a duration in milliseconds into a human-readable time string (for example, 1337000000 becomes “15d 11h 23m 20s”). It’s useful for displaying elapsed times or operation durations with options for compact, verbose, colon style, and sub-second formatting.

Project status

  • Maintenance status: The repository shows ongoing work with the latest documented update v9.3.0 on 2025-09-15 and a recent upstream push on 2025-11-02, so it does not look dormant, though updates are not frequent.
  • Updates cadence (approx.): Recent updates arrive on the order of months to around a year (v9.3.0 in late 2025, v9.2.0 around late 2024, v9.1.0 mid 2024), suggesting a slow, steady cadence rather than rapid iteration.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v9.3.0

    v9.3.0 adds a new `subSecondsAsDecimals` option to `pretty-ms`, allowing sub-second durations (for example `900ms`) to be rendered as decimal seconds (for example `0.9s`). The release notes only document this new option, and the code, type definitions, and README are updated consistently to support it.

    Features
  • v9.2.0

    v9.2.0 adds new formatting options to hide larger time units, specifically year related units and seconds. The implementation changes how the library decomposes days into years/days/hours and conditionally skips the seconds rendering path. It also bumps several devDependencies used for the project tooling and updates tests and TypeScript typings accordingly.

    Features
  • v9.1.0

    v9.1.0 adds support for formatting negative millisecond values in pretty-ms. The main code change is in index.js, where negative inputs are detected and a sign is preserved while the absolute value is formatted. Release notes only mention negative milliseconds support, but the diff also includes CI and dev tool updates.

    Features
  • v9.0.0

    pretty-ms v9.0.0 requires Node.js 18 and adds support for passing BigInt values as the milliseconds input. The implementation also adjusts formatting logic to better handle large values (notably around sub-units and seconds rendering).

    BreakingFeatures
  • v8.0.0

    v8.0.0 converts pretty-ms to a pure ESM package and raises the minimum supported Node.js version to Node 14. The code diff also shows TypeScript type definition reshaping and a major dependency bump (parse-ms), alongside the ESM packaging changes.

    Breaking
  • v7.0.1

    v7.0.1 addresses an issue with how pretty-ms formats sub-second values when the `colonNotation` option is enabled. The code change adjusts the internal logic that decides when to treat `milliseconds < 1000` as “whole seconds” style output, and new tests cover edge cases around 999ms to 1001ms.

  • v7.0.0

    pretty-ms v7.0.0 changes the core time formatting behavior to always floor time values instead of rounding up. The release notes warn that exact string output may differ if you have strict expectations (for example, in unit tests).

    Breaking
  • v6.0.1

    v6.0.1 is a small patch release that adjusts how output strings are assembled when the `colonNotation` option is used. The code specifically changes the separator behavior for the `unitCount` pathway so the formatted units are joined without unwanted spacing.

  • v6.0.0

    pretty-ms v6.0.0 raises the minimum supported Node.js version to 10 and removes the approximate tilde prefix (~) from output when using the compact and unitCount options. It also changes milliseconds rounding behavior to fix an inconsistency, including adjustments near minute boundaries.

    Breaking
  • v5.1.0

    Release v5.1.0 adds a new `colonNotation` option to render durations in a digital-clock style format (for example, `5h 1m 45s` becomes `5:01:45`). The code implements this by introducing colon-specific formatting logic and overriding several existing formatting options when `colonNotation` is enabled.

    Features