mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-31 23:59:35 +03:00
Fix bug in duration format logic (#2026)
This commit is contained in:
parent
68ceeb9ea1
commit
c4d1569441
@ -19,7 +19,7 @@ export const formatDuration = (d) => {
|
||||
const f = [hours, minutes, seconds]
|
||||
.map((v) => v.toString())
|
||||
.map((v) => (v.length !== 2 ? '0' + v : v))
|
||||
.filter((v, i) => v !== '00' || i > 0)
|
||||
.filter((v, i) => v !== '00' || i > 0 || days > 0)
|
||||
.join(':')
|
||||
|
||||
return `${days > 0 ? days + ':' : ''}${f}`
|
||||
|
@ -27,5 +27,7 @@ describe('formatDuration', () => {
|
||||
expect(formatDuration(3 * day + 3 * hour + 7 * minute)).toEqual(
|
||||
'3:03:07:00'
|
||||
)
|
||||
expect(formatDuration(day)).toEqual('1:00:00:00')
|
||||
expect(formatDuration(day + minute + 0.6)).toEqual('1:00:01:01')
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user