From 7b6c780c0a237f7d78697c9f82f67c289b7600dc Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 6 May 2023 13:24:55 +0800 Subject: [PATCH] fix(nc-gui): revise copy datetime logic --- packages/nc-gui/composables/useMultiSelect/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/composables/useMultiSelect/index.ts b/packages/nc-gui/composables/useMultiSelect/index.ts index 0aa9f2fbeb..09e4903bed 100644 --- a/packages/nc-gui/composables/useMultiSelect/index.ts +++ b/packages/nc-gui/composables/useMultiSelect/index.ts @@ -117,16 +117,21 @@ export function useMultiSelect( } if (columnObj.uidt === UITypes.DateTime) { + let d = dayjs(textToCopy) + if (!d.isValid()) { + // e.g. textToCopy = 2023-05-06T05:12:29.000Z + // feed custom parse format + d = dayjs(textToCopy, isMysql(columnObj.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ') + } if (isXcdbBase(meta.value?.base_id)) { if (isMssql(meta.value?.base_id)) { - textToCopy = dayjs(textToCopy).format(constructDateTimeFormat(columnObj)) + textToCopy = d.format(constructDateTimeFormat(columnObj)) } else { - textToCopy = dayjs(textToCopy).utc(true).local().format(constructDateTimeFormat(columnObj)) + textToCopy = d.utc(true).local().format(constructDateTimeFormat(columnObj)) } } else { - textToCopy = dayjs(textToCopy).format(constructDateTimeFormat(columnObj)) + textToCopy = d.format(constructDateTimeFormat(columnObj)) } - if (!dayjs(textToCopy).isValid()) { throw new Error('Invalid Date') }