fixing formatSeconds for negative values

practiced-songs
Matthew Huntington 1 year ago
parent 66cc5fbdc6
commit 54c825827f

@ -19,12 +19,15 @@ const getAccumulatedSeconds = (newerTime, olderTime) => {
}
const formatSeconds = (total, includeHours = false) => {
const timeObj = createTimeObj(total)
const timeObj = createTimeObj(Math.abs(total))
let result = (total < 0) ? '-' : ''
if(includeHours) {
return `${timeObj.hours}:${timeObj.minutes.toString().padStart(2,'0')}:${timeObj.seconds.toString().padStart(2,'0')}`;
result += `${timeObj.hours}:${timeObj.minutes.toString().padStart(2,'0')}`
} else {
return `${timeObj.hours*60 + timeObj.minutes}:${timeObj.seconds.toString().padStart(2,'0')}`;
result += `${timeObj.hours*60 + timeObj.minutes}`
}
result += `:${timeObj.seconds.toString().padStart(2,'0')}`
return result
}
export { getHours, getMinutes, createTimeObj, getAccumulatedSeconds, formatSeconds }

Loading…
Cancel
Save