From af5c2b5a42ed8b1038f8434ff64bab78378360a4 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 10 Oct 2022 21:28:58 -0400 Subject: [PATCH] Round song duration (instead of truncating it). Relates to #1926 --- ui/src/utils/formatters.js | 2 +- ui/src/utils/formatters.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/utils/formatters.js b/ui/src/utils/formatters.js index 3474f5cb..f7c658e4 100644 --- a/ui/src/utils/formatters.js +++ b/ui/src/utils/formatters.js @@ -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)) diff --git a/ui/src/utils/formatters.test.js b/ui/src/utils/formatters.test.js index 6b6163d7..c4102fb9 100644 --- a/ui/src/utils/formatters.test.js +++ b/ui/src/utils/formatters.test.js @@ -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', () => {