Also add local version of short date time format (#1211)
This commit is contained in:
@@ -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() {
|
||||
<Label className="text-sm text-slate-400">Created</Label>
|
||||
<span
|
||||
className="truncate text-sm"
|
||||
title={basicLocalTimeFormat(currentRunningTask.created_at)}
|
||||
title={timeFormatWithShortDate(
|
||||
currentRunningTask.created_at,
|
||||
)}
|
||||
>
|
||||
{currentRunningTask &&
|
||||
timeFormatWithShortDate(currentRunningTask.created_at)}
|
||||
localTimeFormatWithShortDate(
|
||||
currentRunningTask.created_at,
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-auto flex justify-end">
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user