mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 00:59:01 +08:00
Fix(FE): Fix date dashboard (#311)
* chore: getFormatedDate function is added * fix: date format in the all dashboard is updated to mm/dd/yyyy HH:MM
This commit is contained in:
parent
e756cefa75
commit
cc91242e9a
@ -1,5 +1,6 @@
|
||||
import { Typography } from 'antd';
|
||||
import convertDateToAmAndPm from 'lib/convertDateToAmAndPm';
|
||||
import getFormattedDate from 'lib/getFormatedDate';
|
||||
import React from 'react';
|
||||
|
||||
import { Data } from '..';
|
||||
@ -7,11 +8,11 @@ import { Data } from '..';
|
||||
const Created = (createdBy: Data['createdBy']): JSX.Element => {
|
||||
const time = new Date(createdBy);
|
||||
|
||||
return (
|
||||
<Typography>{`${time.toLocaleDateString()} ${convertDateToAmAndPm(
|
||||
time,
|
||||
)}`}</Typography>
|
||||
);
|
||||
const date = getFormattedDate(time);
|
||||
|
||||
const timeString = `${date} ${convertDateToAmAndPm(time)}`;
|
||||
|
||||
return <Typography>{`${timeString}`}</Typography>;
|
||||
};
|
||||
|
||||
export default Created;
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { Typography } from 'antd';
|
||||
import convertDateToAmAndPm from 'lib/convertDateToAmAndPm';
|
||||
import getFormattedDate from 'lib/getFormatedDate';
|
||||
import React from 'react';
|
||||
|
||||
import { Data } from '..';
|
||||
@ -6,9 +8,13 @@ import { Data } from '..';
|
||||
const DateComponent = (
|
||||
lastUpdatedTime: Data['lastUpdatedTime'],
|
||||
): JSX.Element => {
|
||||
const date = new Date(lastUpdatedTime).toDateString();
|
||||
const time = new Date(lastUpdatedTime);
|
||||
|
||||
return <Typography>{date}</Typography>;
|
||||
const date = getFormattedDate(time);
|
||||
|
||||
const timeString = `${date} ${convertDateToAmAndPm(time)}`;
|
||||
|
||||
return <Typography>{timeString}</Typography>;
|
||||
};
|
||||
|
||||
export default DateComponent;
|
||||
|
@ -49,13 +49,22 @@ const ListOfAllDashboard = (): JSX.Element => {
|
||||
{
|
||||
title: 'Created At',
|
||||
dataIndex: 'createdBy',
|
||||
sorter: (a: Data, b: Data): number => {
|
||||
const prev = new Date(a.createdBy).getTime();
|
||||
const next = new Date(b.createdBy).getTime();
|
||||
|
||||
return prev - next;
|
||||
},
|
||||
render: Createdby,
|
||||
},
|
||||
{
|
||||
title: 'Last Updated Time',
|
||||
dataIndex: 'lastUpdatedTime',
|
||||
sorter: (a: Data, b: Data): number => {
|
||||
return parseInt(a.lastUpdatedTime, 10) - parseInt(b.lastUpdatedTime, 10);
|
||||
const prev = new Date(a.lastUpdatedTime).getTime();
|
||||
const next = new Date(b.lastUpdatedTime).getTime();
|
||||
|
||||
return prev - next;
|
||||
},
|
||||
render: DateComponent,
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
const convertDateToAmAndPm = (date: Date): string => {
|
||||
return date.toLocaleString('en-US', {
|
||||
hour: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: 'numeric',
|
||||
hour12: true,
|
||||
});
|
||||
|
13
frontend/src/lib/getFormatedDate.ts
Normal file
13
frontend/src/lib/getFormatedDate.ts
Normal file
@ -0,0 +1,13 @@
|
||||
function getFormattedDate(date: Date): string {
|
||||
const year = date.getFullYear();
|
||||
|
||||
let month = (1 + date.getMonth()).toString();
|
||||
month = month.length > 1 ? month : '0' + month;
|
||||
|
||||
let day = date.getDate().toString();
|
||||
day = day.length > 1 ? day : '0' + day;
|
||||
|
||||
return month + '/' + day + '/' + year;
|
||||
}
|
||||
|
||||
export default getFormattedDate;
|
Loading…
x
Reference in New Issue
Block a user