Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions airflow-core/src/airflow/ui/src/utils/datetimeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import { describe, it, expect } from "vitest";
import { getDuration, renderDuration } from "./datetimeUtils";

describe("getDuration", () => {
it("handles durations less than 10 seconds", () => {
it("handles durations less than 60 seconds", () => {
const start = "2024-03-14T10:00:00.000Z";
const end = "2024-03-14T10:00:05.500Z";
const end = "2024-03-14T10:00:05.5111111Z";

expect(getDuration(start, end)).toBe("5.50s");
expect(getDuration(start, end)).toBe("00:00:05.511");
});

it("handles durations spanning multiple days", () => {
Expand Down
6 changes: 3 additions & 3 deletions airflow-core/src/airflow/ui/src/utils/datetimeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const renderDuration = (durationSeconds: number | null | undefined): stri
return undefined;
}

// If under 10 seconds, render as 9s
if (durationSeconds < 10) {
return `${durationSeconds.toFixed(2)}s`;
// If under 60 seconds, render milliseconds
if (durationSeconds < 60) {
return dayjs.duration(Number(durationSeconds.toFixed(3)), "seconds").format("HH:mm:ss.SSS");
}

// If under 1 day, render as HH:mm:ss otherwise include the number of days
Expand Down