forked from pytest-dev/pytest-html
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.js
More file actions
24 lines (20 loc) · 743 Bytes
/
utils.js
File metadata and controls
24 lines (20 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const formattedNumber = (number) =>
number.toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false,
})
const formatDuration = ( totalSeconds ) => {
if (totalSeconds < 1) {
return {ms: `${Math.round(totalSeconds * 1000)} ms`}
}
const hours = Math.floor(totalSeconds / 3600)
let remainingSeconds = totalSeconds % 3600
const minutes = Math.floor(remainingSeconds / 60)
remainingSeconds = remainingSeconds % 60
const seconds = Math.round(remainingSeconds)
return {
seconds: `${Math.round(totalSeconds)} seconds`,
formatted: `${formattedNumber(hours)}:${formattedNumber(minutes)}:${formattedNumber(seconds)}`,
}
}
module.exports = { formatDuration }