diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx index be390690..177f6bd1 100644 --- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx +++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx @@ -35,6 +35,7 @@ import { apiBaseUrl, envCredential } from "@/util/env"; import { basicLocalTimeFormat, basicTimeFormat, + localTimeFormatWithShortDate, timeFormatWithShortDate, } from "@/util/timeFormat"; import { cn } from "@/util/utils"; @@ -475,10 +476,14 @@ function WorkflowRun() { {currentRunningTask && - timeFormatWithShortDate(currentRunningTask.created_at)} + localTimeFormatWithShortDate( + currentRunningTask.created_at, + )}
diff --git a/skyvern-frontend/src/util/timeFormat.ts b/skyvern-frontend/src/util/timeFormat.ts index dcb7d275..62a57460 100644 --- a/skyvern-frontend/src/util/timeFormat.ts +++ b/skyvern-frontend/src/util/timeFormat.ts @@ -42,7 +42,34 @@ function timeFormatWithShortDate(time: string): string { const dateString = date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear(); const timeString = date.toLocaleTimeString("en-US"); + return `${dateString} at ${timeString} UTC`; +} + +function localTimeFormatWithShortDate(time: string): string { + // Adjust the fractional seconds to milliseconds (3 digits) + time = time.replace(/\.(\d{3})\d*/, ".$1"); + + // Append 'Z' to indicate UTC time if not already present + if (!time.endsWith("Z")) { + time += "Z"; + } + + const date = new Date(time); + const localTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + + const dateString = + date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear(); + + const timeString = date.toLocaleTimeString("en-US", { + timeZone: localTimezone, + }); + return `${dateString} at ${timeString}`; } -export { basicLocalTimeFormat, basicTimeFormat, timeFormatWithShortDate }; +export { + basicLocalTimeFormat, + basicTimeFormat, + timeFormatWithShortDate, + localTimeFormatWithShortDate, +};