jsmreese/moment-duration-format

a negative number(-1 days) appears in the result

thelastto opened this issue · 3 comments

moment.duration(5270100, 'seconds').format('y [years] M [months] D [days] h [hours] m [minutes] s [seconds]', {
    largest: 3
  })
// "2 months -1 days 23 hours"

Thank you. More floating point rounding issues and related to #121.

I get to for weeks

moment.duration(28941549102).format({ template: 'y [years], M [months], w [weeks], d [days], h [hours], m [minutes], s [seconds], S [milliseconds]', largest: 2, trim: 'both mid', useSignificantDigits: true })
// 11 months and -1 weeks

I made this comment on a sunday when the issue was happening now that it's monday the issue is fixed 🤷‍♂️

I'm having the same problem and I made this fiddlejs https://jsfiddle.net/51fzqxbs/ which recreates it. Found out that the bug was introduced in 2.0.0 (if you change the version of the cdn script between 1.3.0 and 2.0.0 you can see it changing from returning a 0 to -1 day)