From 57b5eb7e95ef2556771a9aaaac0c4b3d88210330 Mon Sep 17 00:00:00 2001 From: Yinyin Liu Date: Wed, 19 Feb 2025 10:52:34 +0100 Subject: [PATCH] fix Time column in History of Action tab --- .../content/dashboards/History/History.tsx | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/typescript/frontend-marios2/src/content/dashboards/History/History.tsx b/typescript/frontend-marios2/src/content/dashboards/History/History.tsx index e2a953e92..afb629aa6 100644 --- a/typescript/frontend-marios2/src/content/dashboards/History/History.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/History/History.tsx @@ -25,10 +25,15 @@ import Button from '@mui/material/Button'; import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; import EditIcon from '@mui/icons-material/Edit'; import DeleteIcon from '@mui/icons-material/Delete'; import { UserContext } from '../../../contexts/userContext'; +dayjs.extend(utc); +dayjs.extend(timezone); + interface HistoryProps { errorLoadingS3Data: boolean; id: number; @@ -411,14 +416,18 @@ function HistoryOfActions(props: HistoryProps) {
{history.map((action, index) => { - // Parse the timestamp string to a Date object - const date = new Date(action.timestamp); + // // Parse the timestamp string to a Date object + // const date = new Date(action.timestamp); + // + // // Extract the date part (e.g., "2023-05-31") + // const datePart = date.toLocaleDateString(); + // + // // Extract the time part (e.g., "12:34:56") + // const timePart = date.toLocaleTimeString(); + const dateCET = dayjs.utc(action.timestamp).tz("Europe/Paris"); + const datePart = dateCET.format("YYYY-MM-DD"); + const timePart = dateCET.format("HH:mm:ss"); - // Extract the date part (e.g., "2023-05-31") - const datePart = date.toLocaleDateString(); - - // Extract the time part (e.g., "12:34:56") - const timePart = date.toLocaleTimeString(); const iconStyle = action.userName === currentUser.name ? {}