GitShow/sindresorhus/pretty-ms
sindresorhus

pretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`

by sindresorhus
humanizemillisecondsnpm-package
Star on GitHubForknpm

JavaScript

1.2k stars69 forks22 contributorsActive · 1mo agoSince 2014v9.3.0MIT

Meet the team

See all 22 on GitHub →
sindresorhus
sindresorhus66 contributions
fisker
fisker4 contributions
icyflame
icyflame3 contributions
villebro
villebro3 contributions
arnellebalane
arnellebalane2 contributions
Richienb
Richienb2 contributions
kevva
kevva2 contributions
ehmicky
ehmicky1 contribution

Languages

View on GitHub →
JavaScript96.2%
TypeScript3.8%

Commit activity

Last 12 weeks · 1 commit

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Active · 1 in progress · Last activity 1mo ago
See all on GitHub →
spokodev
Prevent the milliseconds component rounding up to 1000msOpenPR

With , the sub-second component is rounded independently of the seconds, so a fractional value near the boundary rounds up to and is emitted as its own unit — an impossible combination: The milliseconds unit only ranges 0–999, so should never appear. This is the same "rounding rolls a unit past its max" class as the seconds→ issue (#38), which is handled for seconds by flooring (), but the separate-milliseconds component still used a bare . Fix Cap the rounded component at so it stays within range: Output becomes / — valid unit combinations, consistent with how the seconds component is kept below 60. Non-boundary values are unaffected ( → , → ). Tests Three regression cases added to the test; they produce the impossible output before the change and pass after. Full suite green.

spokodev · 34m ago

Recent fixes

View closed PRs →
TomerAberbach
Formatted difference inconsistent with formatted endpoints: `prettyMilliseconds(b − a)` vs `prettyMilliseconds(a)` and `prettyMilliseconds(b)`ClosedIssue

I have the following situation: 1. I have and 2. I display , , and to the end-user 3. The result looks wrong because (conceptually) does not equal (due to rounding) Example: Wondering how you'd suggest to handle this? One idea: expose the rounded numeric value alongside the string (e.g. a -style API, or output), so callers can compute the delta from the values as displayed instead of from the raw inputs. Alternatively, an option to format a set of related values consistently (shared unit and precision). The same issue happens in .

TomerAberbach · 1mo ago
suryaashish-tyke
Feature Request: add support for monthsClosedIssue

Suppose if the actual age is 54days can we show it as 1mo24d

suryaashish-tyke · 10mo ago
ulken
Option to output sub-second as decimal secondsClosedIssue

@sindresorhus Would you accept a PR that takes an option to keep the decimals on whole numbers? I'm using this library for a progress indicator thingy which keeps updating the time spent every ~60ms or so, and it keeps flickering in the terminal when it hits a whole number - I'd prefer if it just kept the fixed length as specified. @sindresorhus For the same reason, I would find it preferable if sub-seconds could be output as seconds. I.e. -> . Right now I'm wrapping and adding the logic myself, but does it qualify for an option to be included in the library? _Originally posted by @ulken in https://github.com/sindresorhus/pretty-ms/issues/20#issuecomment-1825457807_

ulken · 11mo ago
Structured data for AI agents

Repository: sindresorhus/pretty-ms. Description: Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s` Stars: 1215, Forks: 69. Primary language: JavaScript. Languages: JavaScript (96.2%), TypeScript (3.8%). License: MIT. Topics: humanize, milliseconds, npm-package. Latest release: v9.3.0 (11mo ago). Open PRs: 1, open issues: 0. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, fisker, icyflame, villebro, arnellebalane, Richienb, kevva, ehmicky, OyuNet, Rich-Harris and others.

·@ofershap

Replace github.com with gitshow.dev