Skip to content

🎧 Your Personal Streaming Service

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

Deluanaf5c2b5a42ed
diff --git a/ui/src/utils/formatters.js b/ui/src/utils/formatters.js
index 3474f5cb7..f7c658e40 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 6b6163d7d..c4102fb92 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', () => {