jsmreese / moment-duration-format

Format function plugin for the Moment Duration object.
MIT License
967 stars 121 forks source link

Formatting is not calculating properly when trying to display minutes through year #139

Closed Btan579 closed 4 years ago

Btan579 commented 4 years ago
 const yearMinutes = moment.duration(1, 'years').format('m [minute]');
// returns 525600
 const minutesYear = moment.duration(525600, 'minutes').format('y [year] M [months] w [weeks] d [days] h [hours] m [minutes]', { trim: 'both mid' });
//returns 11 months 4 weeks 2 days

minutesYear should return as 1 year

Playing around a bit, this problem only seems to occur for me when month and week are added into the formatting. If you omit month and week it will display properly as 1 year

Btan579 commented 4 years ago

Oddly when you get to exactly 525950 it starts account for the year. it will display as 1 year 5 hours 50 minutes. But if you input 525949 it changes over to 52 weeks 1 day 5 hours 49 minutes.

Btan579 commented 4 years ago

I was able to resolve the problem. I was causing on my end with some looping.