fix export crash due to toDate issue

This commit is contained in:
Bobby Wang
2023-04-01 02:37:14 +13:00
parent d9927bdfc8
commit a91b751995
2 changed files with 14 additions and 4 deletions

View File

@@ -35,8 +35,13 @@ export const config: IFieldConfig = {
filter: { operators: filterOperators, valueFormatter },
settings: Settings,
csvImportParser: (value, config) => parse(value, DATE_FORMAT, new Date()),
csvExportFormatter: (value: any, config?: any) =>
format(value.toDate(), DATE_FORMAT),
csvExportFormatter: (value: any, config?: any) => {
if (typeof value === "number") {
return format(new Date(value), DATE_FORMAT);
} else {
return format(value.toDate(), DATE_FORMAT);
}
},
};
export default config;

View File

@@ -47,8 +47,13 @@ export const config: IFieldConfig = {
},
settings: Settings,
csvImportParser: (value) => new Date(value),
csvExportFormatter: (value: any, config?: any) =>
format(value.toDate(), DATE_TIME_FORMAT),
csvExportFormatter: (value: any, config?: any) => {
if (typeof value === "number") {
return format(new Date(value), config?.format || DATE_TIME_FORMAT);
} else {
return format(value.toDate(), config?.format || DATE_TIME_FORMAT);
}
},
};
export default config;