anylongdurations: Durations that read like language: two hours thirty, from whatever shape you already have.

anylong
about anylong

Writes a duration down — "2 hr, 30 min", "2:30:00", "2 часа 30 минут" — from milliseconds, seconds, an ISO 8601 string, shorthand like "2h 30m", a record, or two Dates.

wraps
Intl.DurationFormat
install
npm install anylong
runtime
Node 23+, Chrome 129+, Firefox 132+, Safari 16.4+ (Baseline 2025) — branch on anylong.supported for older engines.
docs
anyfamily.site/docs/anylong
playground
run the family on StackBlitz

why

Duration strings by hand are a pile of pluralised ifs that only work in English; humanize-duration bundles its own languages. anylong accepts every reasonable input, formats natively in any locale, and refuses ambiguous input like "1:30" instead of guessing.

usage

anylong(9_000_000)                                        // "2 hr, 30 min"
anylong("PT2H30M", { locale: "ru" })                      // "2 ч 30 мин"
anylong("2 hours 30 minutes", { style: "long" })          // "2 hours, 30 minutes"
anylong({ hours: 2, minutes: 30 }, { style: "digital" })  // "2:30:00"
anylong(startedAt, finishedAt)                            // between two Dates, order-independent
anylong.supported                                         // false where Intl.DurationFormat is missing

not for

Calendar arithmetic such as months between two dates, countdowns that tick, or negative durations.