Fix bug in duration format logic (#2026)
This commit is contained in:
parent
68ceeb9ea1
commit
c4d1569441
2 changed files with 3 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ export const formatDuration = (d) => {
|
||||||
const f = [hours, minutes, seconds]
|
const f = [hours, minutes, seconds]
|
||||||
.map((v) => v.toString())
|
.map((v) => v.toString())
|
||||||
.map((v) => (v.length !== 2 ? '0' + v : v))
|
.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(':')
|
.join(':')
|
||||||
|
|
||||||
return `${days > 0 ? days + ':' : ''}${f}`
|
return `${days > 0 ? days + ':' : ''}${f}`
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,7 @@ describe('formatDuration', () => {
|
||||||
expect(formatDuration(3 * day + 3 * hour + 7 * minute)).toEqual(
|
expect(formatDuration(3 * day + 3 * hour + 7 * minute)).toEqual(
|
||||||
'3:03:07:00'
|
'3:03:07:00'
|
||||||
)
|
)
|
||||||
|
expect(formatDuration(day)).toEqual('1:00:00:00')
|
||||||
|
expect(formatDuration(day + minute + 0.6)).toEqual('1:00:01:01')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue