npm pretty-ms 10.0.0

10 hours ago

Breaking

  • Require Node.js 22 d4f7c61
  • Ignore unitCount with colonNotation cc2326c
    • Dropping a field from the right changed what the remaining fields meant: 3661000 with unitCount: 2 was 1:01, which reads as 1 minute and 1 second. It is now 1:01:01.
  • Always show the hours with colonNotation and hideSeconds c501a70
    • 60000 was a bare 1. It is now 0:01, so the fields always read as h:mm.
  • Pad the days to 3 digits with colonNotation after a year c77bbd0
    • 1:05:00:00:00 is now 1:005:00:00:00, so the width does not change between 9 and 100 days.
  • The output changed for many edge cases (see the fixes below). It's probably not breaking for most users, but if you depend on the exact output, for example, in unit tests, the output might have changed slightly.

Improvements

  • Remove the parse-ms dependency 4cdc911
  • Remove float noise from fractional input 4cdc911
    • A fractional number is now read to 15 significant digits, so 999.9999999999999 is 1s, not 999ms. An integer (number or bigint) is exact at any size. Learn more.

Fixes

  • Fix fractional seconds rounding up into the next unit (#76) 0127f97 614a6ec
    • 1999.999999 was 2s, and 59999.999999 was 60s. They are now 1.9s and 59.9s.
  • Fix the seconds losing precision for large durations and high digit counts 34b9a49 c0c8ec5 1ce8d2d
    • 40176002900 with secondsDecimalDigits: 2 was 1y 100d 2.89s. It is now 1y 100d 2.90s.
  • Fix the days, hours, and minutes for very large durations fa0e801
    • 1e22 showed 18h 36m instead of 17h 46m.
  • Fix the sub-millisecond fields a7dc168 7a2453a 29a30b3
    • 0.00397 with formatSubMilliseconds was 3µs 969ns, and 1234567890123 showed a phantom 64ns.
  • Round the decimal milliseconds half up correctly c1f30cb
    • 1.005 with millisecondsDecimalDigits: 2 was 1.00ms. It is now 1.01ms.
  • Never show a nonzero duration as 0ms 124a6ee 8b2dff2
  • Never show a negative zero, like -0ms 2727b38
  • Fix hideSeconds showing 0ms for a duration under a minute 618aae9
    • 45000 is now 45s, as there is no larger unit to show.
  • Fix subSecondsAsDecimals showing 0ms when the seconds cannot show the value b884336
    • 50 was 0ms. It is now 50ms.
  • Fix secondsDecimalDigits and millisecondsDecimalDigits throwing a RangeError for values outside 0-100, and showing NaNs for NaN b9c75fc
  • Fix unitCount: NaN returning an empty string c00947e

v9.3.1...v10.0.0

Don't miss a new pretty-ms release

NewReleases is sending notifications on new releases.