fix TimeCellProps

This commit is contained in:
Ishaan Jaff 2025-02-01 16:12:35 -08:00
parent d8774bb53d
commit 2734fac591
2 changed files with 40 additions and 3 deletions

View file

@ -5,6 +5,7 @@ import React from "react";
import { CountryCell } from "./country_cell";
import { getProviderLogoAndName } from "../provider_info_helpers";
import { Tooltip } from "antd";
import { TimeCell } from "./time_cell";
export type LogEntry = {
request_id: string;
@ -53,9 +54,7 @@ export const columns: ColumnDef<LogEntry>[] = [
{
header: "Time",
accessorKey: "startTime",
cell: (info: any) => (
<span>{moment(info.getValue()).format("MMM DD HH:mm:ss")}</span>
),
cell: (info: any) => <TimeCell utcTime={info.getValue()} />,
},
{
header: "Request ID",

View file

@ -0,0 +1,38 @@
import * as React from "react";
interface TimeCellProps {
utcTime: string;
}
const getLocalTime = (utcTime: string): string => {
try {
const date = new Date(utcTime);
return date.toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
}).replace(',', '');
} catch (e) {
return "Error converting time";
}
};
export const TimeCell: React.FC<TimeCellProps> = ({ utcTime }) => {
return (
<span style={{
fontFamily: 'monospace',
width: '180px',
display: 'inline-block'
}}>
{getLocalTime(utcTime)}
</span>
);
};
export const getTimeZone = (): string => {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
};