From 041bf96ada5d8749013bbec211caad5eaf7b7315 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 20 Oct 2022 14:15:50 +0800 Subject: [PATCH] fix(nc-gui): handle invalid date cases in import --- packages/nc-gui/components/template/Editor.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index f3fb974daa..3b5e2f439c 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -244,9 +244,13 @@ function remapColNames(batchData: any[], columns: ColumnType[]) { dateFormat = getDateFormat(d) dateFormatMap[col.key] = dateFormat } - d = dayjs(d).utc().format(dateFormat) + const dayjsObj = dayjs(d) + if (dayjsObj.isValid()) { + d = dayjsObj.format('YYYY-MM-DD') + } else { + d = dayjs(d, dateFormat).format('YYYY-MM-DD') + } } else if (col.uidt === UITypes.DateTime && d) { - // TODO: handle more formats for DateTime d = dayjs(data[key]).utc().format('YYYY-MM-DD HH:mm') } return {