diff --git a/web/components/shared/themed/table/requestRow.tsx b/web/components/shared/themed/table/requestRow.tsx
index e54049c577..7f40357c66 100644
--- a/web/components/shared/themed/table/requestRow.tsx
+++ b/web/components/shared/themed/table/requestRow.tsx
@@ -6,6 +6,7 @@ import { formatNumber } from "../../../templates/users/initialColumns";
import { clsx } from "../../clsx";
import { useState } from "react";
import CostPill from "../../../templates/requestsV2/costPill";
+import { getLocalDateFormat, getUSDateFromString } from "../../utils/utils";
interface RequestRowProps {
index: number;
@@ -42,7 +43,7 @@ const RequestRow = (props: RequestRowProps) => {
>
- {new Date(row.createdAt).toLocaleString()}
+ {getUSDateFromString(getLocalDateFormat(row.createdAt))}
{
.slice(-2)}`;
};
+const getLocalDateFormat = (date: string) => {
+ const dateObj = new Date(date);
+ const tzOffset = dateObj.getTimezoneOffset() * 60000;
+
+ const localDateObj = new Date(dateObj.getTime() - tzOffset);
+ const formattedDate =
+ [
+ ("0" + (localDateObj.getMonth() + 1)).slice(-2),
+ ("0" + localDateObj.getDate()).slice(-2),
+ localDateObj.getFullYear(),
+ ].join("/") +
+ " " +
+ [
+ ("0" + localDateObj.getHours()).slice(-2),
+ ("0" + localDateObj.getMinutes()).slice(-2),
+ ("0" + localDateObj.getSeconds()).slice(-2),
+ ].join(":");
+
+ return formattedDate;
+};
+
const capitalizeWords = (str: string) => {
// replace underscores with spaces
const strWithSpaces = str.replace(/_/g, " ");
@@ -89,6 +110,7 @@ function removeLeadingWhitespace(str: string | null): string {
}
export {
+ getLocalDateFormat,
getUSDateFromString,
getUSDate,
getUSDateShort,
diff --git a/web/components/templates/requestsV2/initialColumns.tsx b/web/components/templates/requestsV2/initialColumns.tsx
index fc86365bcb..97836a0152 100644
--- a/web/components/templates/requestsV2/initialColumns.tsx
+++ b/web/components/templates/requestsV2/initialColumns.tsx
@@ -1,5 +1,8 @@
import { ColumnDef } from "@tanstack/react-table";
-import { getUSDateFromString } from "../../shared/utils/utils";
+import {
+ getLocalDateFormat,
+ getUSDateFromString,
+} from "../../shared/utils/utils";
import { NormalizedRequest } from "./builder/abstractRequestBuilder";
import ModelPill from "./modelPill";
import StatusBadge from "./statusBadge";
@@ -25,27 +28,6 @@ function formatNumber(num: number) {
}
}
-const convertToUSDateFormat = (date: string) => {
- const dateObj = new Date(date);
- const tzOffset = dateObj.getTimezoneOffset() * 60000;
-
- const localDateObj = new Date(dateObj.getTime() - tzOffset);
- const formattedDate =
- [
- ("0" + (localDateObj.getMonth() + 1)).slice(-2),
- ("0" + localDateObj.getDate()).slice(-2),
- localDateObj.getFullYear(),
- ].join("/") +
- " " +
- [
- ("0" + localDateObj.getHours()).slice(-2),
- ("0" + localDateObj.getMinutes()).slice(-2),
- ("0" + localDateObj.getSeconds()).slice(-2),
- ].join(":");
-
- return formattedDate;
-};
-
export const getInitialColumns: (
isCached?: boolean
) => ColumnDef[] = (isCached = false) => [
@@ -55,7 +37,7 @@ export const getInitialColumns: (
header: "Created At",
cell: (info) => (
- {getUSDateFromString(convertToUSDateFormat(info.getValue() as string))}
+ {getUSDateFromString(getLocalDateFormat(info.getValue() as string))}
),
meta: {
diff --git a/web/components/templates/requestsV2/requestCard.tsx b/web/components/templates/requestsV2/requestCard.tsx
index e056104153..82522bb782 100644
--- a/web/components/templates/requestsV2/requestCard.tsx
+++ b/web/components/templates/requestsV2/requestCard.tsx
@@ -8,6 +8,10 @@ import CostPill from "./costPill";
import { CustomProperties } from "./customProperties";
import ModelPill from "./modelPill";
import StatusBadge from "./statusBadge";
+import {
+ getLocalDateFormat,
+ getUSDateFromString,
+} from "@/components/shared/utils/utils";
interface RequestCardProps {
request: NormalizedRequest;
@@ -53,7 +57,7 @@ const RequestCard = (props: RequestCardProps) => {
- {new Date(request.createdAt).toLocaleString()}
+ {getUSDateFromString(getLocalDateFormat(request.createdAt))}
{
- const dateObj = new Date(date);
- const tzOffset = dateObj.getTimezoneOffset() * 60000;
-
- const localDateObj = new Date(dateObj.getTime() - tzOffset);
- const formattedDate =
- [
- ("0" + (localDateObj.getMonth() + 1)).slice(-2),
- ("0" + localDateObj.getDate()).slice(-2),
- localDateObj.getFullYear(),
- ].join("/") +
- " " +
- [
- ("0" + localDateObj.getHours()).slice(-2),
- ("0" + localDateObj.getMinutes()).slice(-2),
- ("0" + localDateObj.getSeconds()).slice(-2),
- ].join(":");
-
- return formattedDate;
-};
const RequestRow = (props: {
request: NormalizedRequest;
@@ -234,7 +218,7 @@ const RequestRow = (props: {
Created At
- {convertToUSDateFormat(request.createdAt)}
+ {getUSDateFromString(getLocalDateFormat(request.createdAt))}