Fix 60 seconds (again). Fixes #1956
This commit is contained in:
@@ -11,10 +11,11 @@ export const formatBytes = (bytes, decimals = 2) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const formatDuration = (d) => {
|
export const formatDuration = (d) => {
|
||||||
|
d = Math.round(d)
|
||||||
const days = Math.floor(d / 86400)
|
const days = Math.floor(d / 86400)
|
||||||
const hours = Math.floor(d / 3600) % 24
|
const hours = Math.floor(d / 3600) % 24
|
||||||
const minutes = Math.floor(d / 60) % 60
|
const minutes = Math.floor(d / 60) % 60
|
||||||
const seconds = Math.round(d % 60)
|
const seconds = Math.floor(d % 60)
|
||||||
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))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ describe('formatDuration', () => {
|
|||||||
it('formats seconds', () => {
|
it('formats seconds', () => {
|
||||||
expect(formatDuration(0)).toEqual('00:00')
|
expect(formatDuration(0)).toEqual('00:00')
|
||||||
expect(formatDuration(59)).toEqual('00:59')
|
expect(formatDuration(59)).toEqual('00:59')
|
||||||
expect(formatDuration(59.99)).toEqual('00:60')
|
expect(formatDuration(59.99)).toEqual('01:00')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('formats days, hours and minutes', () => {
|
it('formats days, hours and minutes', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user