sindresorhus / pretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
MIT License
1.08k stars 65 forks source link

Option to output sub-second as decimal seconds #63

Open ulken opened 10 months ago

ulken commented 10 months ago

@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. 900ms -> 0.9s. Right now I'm wrapping pretty-ms 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

sindresorhus commented 10 months ago

PR welcome :)