@talosjs/hour-utils turns a raw duration into a human-friendly breakdown. Pick a source unit (Hour, Minute, Second, or Millisecond), call .convert(value).to(format), and get back the requested components plus a ready-to-display text string. The format you pass drives the return type, so the returned object only contains the fields you asked for.
Installation
Add the package with Bun:Usage
Each unit class exposes a staticconvert method that returns a converter with a .to(format) call. The format string selects which components to compute: d (days), h (hours), m (minutes), s (seconds), combined as dhms, dhm, dh, d, hms, hm, h, ms, m, or s.
text field omits zero components, but always shows at least the smallest requested unit when everything is zero:
When it helps
The typical use is having a duration in one unit and needing to display it as days, hours, minutes, and seconds: uptime, time remaining, time elapsed. You get thetext label without writing the string-building yourself, and the returned shape is typed to the exact format you asked for.
If you only need a plain numeric conversion, that’s just arithmetic (hours * 3600). For full calendar or timezone date math, a date library is the right tool.