jsmreese / moment-duration-format

Format function plugin for the Moment Duration object.
MIT License
968 stars 120 forks source link

Precision chops off digits instead of rounding. #76

Closed jpuffer closed 6 years ago

jpuffer commented 6 years ago

Precision should round to the specified number of digits instead of chopping the last digits off. Chopping the last digits leads to very inaccurate results. For example:

moment.duration(1200,"ms").format("s[s]", 1) -> "1.1s"

moment.duration(1200,"ms").format("s[s]", 5) -> "1.19999s"

jsmreese commented 6 years ago

I've pushed a version of this plugin to the master branch where the default behaviour is rounding, not truncating. If you try the updated version, it should do what you want. Hopefully I'll have it published soon.

jsmreese commented 6 years ago

Closing this. Fixed in 65bde6d59f17dcf15842e032f9ae97da6b0f2bed.