Skip to content

Commit

Permalink
fix: the start and end times are reversed (#8084)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet authored Sep 20, 2024
1 parent cef7f77 commit e524ea7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions config-ui/src/routes/pipeline/components/duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ const duration = (minute: number) => {
}

if (minute < 60) {
return `${Math.ceil(minute / 60)}m`;
return `${minute}m`;
}

if (minute < 60 * 24) {
const hours = Math.floor(minute / 60);
const minutes = minute - hours * 60;
return `${hours}h${minutes}m`;
return `${hours}h${minutes !== 0 ? `${minutes}m` : ''}`;
}

const days = Math.floor(minute / (60 * 24));
const hours = Math.floor((minute - days * 60 * 24) / 60);
const minutes = minute - days * 60 * 24 - hours * 60;

return `${days}d${hours}h${minutes}m`;
return `${days}d${hours !== 0 ? `${hours}h` : ''}${minutes !== 0 ? `${minutes}m` : ''}`;
};

interface Props {
Expand All @@ -58,12 +58,12 @@ export const PipelineDuration = ({ status, beganAt, finishedAt }: Props) => {
status,
)
) {
return <span>{duration(dayjs(beganAt).diff(dayjs(), 'm'))}</span>;
return <span>{duration(dayjs().diff(dayjs(beganAt), 'm'))}</span>;
}

if (!finishedAt) {
return <span>-</span>;
}

return <span>{duration(dayjs(beganAt).diff(dayjs(finishedAt), 'm'))}</span>;
return <span>{duration(dayjs(finishedAt).diff(dayjs(beganAt), 'm'))}</span>;
};

0 comments on commit e524ea7

Please sign in to comment.