1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| export const Duration = ({ value, format }) => {
| if (value === Number.POSITIVE_INFINITY) {
| return "Unknown";
| }
| const formatted = new Date(value * 1000).toISOString().substr(11, 8);
|
| const parsed = formatted.split(":");
|
| const result = format.map((unit) => {
| switch (unit) {
| case "hours":
| return parsed[0];
| case "minutes":
| return parsed[1];
| case "seconds":
| return parsed[2];
| }
| });
|
| return result.join(":");
| };
|
|