Skip to content

Commit eb1bad7

Browse files
committed
fix: display build subtask timing properly regardless of location
1 parent 7a95bf1 commit eb1bad7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

peridot/ui/src/components/ProjectTasksSubtasks.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ import {
4848
translateTaskTypeToText,
4949
} from './ProjectTasks';
5050

51+
52+
function formatDuration(ms) {
53+
const seconds = Math.floor((ms / 1000) % 60);
54+
const minutes = Math.floor((ms / (1000 * 60)) % 60);
55+
const hours = Math.floor((ms / (1000 * 60 * 60)) % 24);
56+
57+
return [hours, minutes, seconds]
58+
.map(val => (val < 10 ? `0${val}` : val)) // Adding leading zeros if necessary
59+
.join(':');
60+
}
61+
5162
export interface ProjectTasksSubtasksProps {
5263
subtasks: V1Subtask[];
5364
}
@@ -79,7 +90,7 @@ export const ProjectTasksSubtasks = (props: ProjectTasksSubtasksProps) => {
7990
(new Date(subtask.finishedAt) as any) -
8091
(new Date(subtask.createdAt) as any);
8192
subtaskDuration = (
82-
<>{new Date(difference - 3600000).toLocaleTimeString()}</>
93+
<>{formatDuration(difference)}</>
8394
);
8495
}
8596

0 commit comments

Comments
 (0)