mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-22 00:49:10 +02:00
Fixes #3817
Correct rounding and carry of minutes in Vue.prototype.$elapsedPrettyExtended -Add cypress tests for Vue.prototype.$elapsedPrettyExtended function
This commit is contained in:
parent
7001adb4dd
commit
acda776e3e
2 changed files with 198 additions and 5 deletions
|
@ -69,17 +69,22 @@ Vue.prototype.$elapsedPrettyExtended = (seconds, useDays = true, showSeconds = t
|
|||
let hours = Math.floor(minutes / 60)
|
||||
minutes -= hours * 60
|
||||
|
||||
// Handle rollovers before days calculation
|
||||
if (minutes && seconds && !showSeconds) {
|
||||
if (seconds >= 30) minutes++
|
||||
if (minutes >= 60) {
|
||||
hours++ // Increment hours if minutes roll over
|
||||
minutes -= 60 // adjust minutes
|
||||
}
|
||||
}
|
||||
|
||||
// Now calculate days with the final hours value
|
||||
let days = 0
|
||||
if (useDays || Math.floor(hours / 24) >= 100) {
|
||||
days = Math.floor(hours / 24)
|
||||
hours -= days * 24
|
||||
}
|
||||
|
||||
// If not showing seconds then round minutes up
|
||||
if (minutes && seconds && !showSeconds) {
|
||||
if (seconds >= 30) minutes++
|
||||
}
|
||||
|
||||
const strs = []
|
||||
if (days) strs.push(`${days}d`)
|
||||
if (hours) strs.push(`${hours}h`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue