Fix timeformat
This commit is contained in:
parent
722ad16e3c
commit
9d5b3bc2c0
@ -15,6 +15,7 @@ import { useParams } from 'react-router-dom';
|
|||||||
import { downloadReport } from 'request/report';
|
import { downloadReport } from 'request/report';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { SheetViewer } from "react-office-viewer";
|
import { SheetViewer } from "react-office-viewer";
|
||||||
|
import { datetimeStrToDate } from 'utils/time';
|
||||||
|
|
||||||
export interface ReportFormValues {
|
export interface ReportFormValues {
|
||||||
dateRange: [Dayjs, Dayjs];
|
dateRange: [Dayjs, Dayjs];
|
||||||
@ -127,13 +128,13 @@ const ReportDetail = () => {
|
|||||||
<Typography.Title level={5}>
|
<Typography.Title level={5}>
|
||||||
Start date:{' '}
|
Start date:{' '}
|
||||||
<span style={{ fontWeight: '400' }}>
|
<span style={{ fontWeight: '400' }}>
|
||||||
{report_data?.metadata?.start_at.split('T')[0]}
|
{datetimeStrToDate(report_data?.metadata?.start_at, 'Asia/Singapore')}
|
||||||
</span>
|
</span>
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Typography.Title level={5}>
|
<Typography.Title level={5}>
|
||||||
End date:{' '}
|
End date:{' '}
|
||||||
<span style={{ fontWeight: '400' }}>
|
<span style={{ fontWeight: '400' }}>
|
||||||
{report_data?.metadata?.end_at.split('T')[0]}
|
{datetimeStrToDate(report_data?.metadata?.end_at, 'Asia/Singapore')}
|
||||||
</span>
|
</span>
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
</HeaderContainer>
|
</HeaderContainer>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
export function datetimeStrToDate(dateTimeStr: string, targetTimeZone: string): string {
|
export function datetimeStrToDate(dateTimeStr: string, targetTimeZone: string): string {
|
||||||
|
if (!dateTimeStr) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
const options: Intl.DateTimeFormatOptions = { timeZone: targetTimeZone, year: 'numeric', month: '2-digit', day: '2-digit' };
|
const options: Intl.DateTimeFormatOptions = { timeZone: targetTimeZone, year: 'numeric', month: '2-digit', day: '2-digit' };
|
||||||
const date = new Date(dateTimeStr);
|
const date = new Date(dateTimeStr);
|
||||||
const convertedDateTimeStr = date.toLocaleDateString('en-US', options).split('/').reverse().join('-');
|
const convertedDateTimeStr = date.toLocaleDateString('en-US', options).split('/').reverse().join('-');
|
||||||
|
Loading…
Reference in New Issue
Block a user