Skip to content

Commit b14219c

Browse files
fix: prevent 1970 in formatDateTime
1 parent 549e848 commit b14219c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/components/InfoViewer/formatters/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {createInfoFormatter} from '../utils';
77
export const formatCommonItem = createInfoFormatter<TDirEntry>({
88
values: {
99
PathType: (value) => value?.substring('EPathType'.length),
10-
CreateStep: (value) => (Number(value) ? formatDateTime(value) : EMPTY_DATA_PLACEHOLDER),
10+
CreateStep: (value) => formatDateTime(value, {defaultValue: EMPTY_DATA_PLACEHOLDER}),
1111
},
1212
labels: {
1313
PathType: i18n('common.type'),

src/utils/dataFormatters/dataFormatters.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ export const formatDateTime = (
215215
value?: number | string,
216216
{withTimeZone, defaultValue = ''}: {withTimeZone?: boolean; defaultValue?: string} = {},
217217
) => {
218+
// prevent 1970-01-01 03:00
219+
if (!Number(value)) {
220+
return defaultValue;
221+
}
222+
218223
const tz = withTimeZone ? ' z' : '';
219224
const formattedData = dateTimeParse(Number(value))?.format(`YYYY-MM-DD HH:mm${tz}`);
220225

0 commit comments

Comments
 (0)