I am trying to build a calculator for the worked hours during the week. I found a way of getting a total of worked hours, but as expected Moment.js bubbles up (for example) the 29hours and 40mins to 1day 5hrs 40mins.
How do I manipulate or stop that default behavior of Moment.js?
Here is what I tried
const calculateTotal = function (arr) {
let hoursInTotal = moment.duration({
minutes: 0,
hours: 0,
});
// arr is the Array I am storing the total hours of each DAY
arr.forEach(function (el) {
// Adding every total hours of each DAY to get the total from EVERY DAY
hoursInTotal.add(el.hours.total);
})
// I am getting 35.25hrs, for example. I want to get 35(h):15(min)
console.log(hoursInTotal.hours());
return hoursInTotal;
}