Round song duration (instead of truncating it). Relates to #1926

This commit is contained in:
Deluan 2022-10-10 21:28:58 -04:00
parent 62e7492357
commit af5c2b5a42
2 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ export const formatDuration = (d) => {
const days = Math.floor(d / 86400)
const hours = Math.floor(d / 3600) % 24
const minutes = Math.floor(d / 60) % 60
const seconds = Math.floor(d % 60)
const seconds = Math.round(d % 60)
const f = [hours, minutes, seconds]
.map((v) => v.toString())
.map((v) => (v.length !== 2 ? '0' + v : v))

View File

@ -19,7 +19,7 @@ describe('formatDuration', () => {
it('formats seconds', () => {
expect(formatDuration(0)).toEqual('00:00')
expect(formatDuration(59)).toEqual('00:59')
expect(formatDuration(59.99)).toEqual('00:59')
expect(formatDuration(59.99)).toEqual('00:60')
})
it('formats days, hours and minutes', () => {