Skip to content

Commit

Permalink
fix: display build subtask timing properly regardless of location
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilHanlon committed Feb 21, 2024
1 parent 7a95bf1 commit eb1bad7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion peridot/ui/src/components/ProjectTasksSubtasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ import {
translateTaskTypeToText,
} from './ProjectTasks';


function formatDuration(ms) {
const seconds = Math.floor((ms / 1000) % 60);
const minutes = Math.floor((ms / (1000 * 60)) % 60);
const hours = Math.floor((ms / (1000 * 60 * 60)) % 24);

return [hours, minutes, seconds]
.map(val => (val < 10 ? `0${val}` : val)) // Adding leading zeros if necessary
.join(':');
}

export interface ProjectTasksSubtasksProps {
subtasks: V1Subtask[];
}
Expand Down Expand Up @@ -79,7 +90,7 @@ export const ProjectTasksSubtasks = (props: ProjectTasksSubtasksProps) => {
(new Date(subtask.finishedAt) as any) -
(new Date(subtask.createdAt) as any);
subtaskDuration = (
<>{new Date(difference - 3600000).toLocaleTimeString()}</>
<>{formatDuration(difference)}</>
);
}

Expand Down

0 comments on commit eb1bad7

Please sign in to comment.