From a069474200b02c7d480c5059f6d945b815d5ab79 Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 30 Jun 2023 10:53:55 +0300 Subject: [PATCH] fix: copy time after paste Signed-off-by: mertmit --- .../nc-gui/composables/useMultiSelect/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useMultiSelect/index.ts b/packages/nc-gui/composables/useMultiSelect/index.ts index b74d7ceede..39a717737c 100644 --- a/packages/nc-gui/composables/useMultiSelect/index.ts +++ b/packages/nc-gui/composables/useMultiSelect/index.ts @@ -163,8 +163,19 @@ export function useMultiSelect( const isMySQL = isMysql(columnObj.base_id) const isPostgres = isPg(columnObj.base_id) - // MySQL and Postgres store time in HH:mm:ss format so we need to feed custom parse format - const d = isMySQL || isPostgres ? dayjs(textToCopy, 'HH:mm:ss') : dayjs(textToCopy) + let d = dayjs(textToCopy) + + if (!d.isValid()) { + // insert a datetime value, copy the value without refreshing + // e.g. textToCopy = 2023-05-12T03:49:25.000Z + // feed custom parse format + d = dayjs(textToCopy, isMySQL ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ') + } + + if (!d.isValid()) { + // MySQL and Postgres store time in HH:mm:ss format so we need to feed custom parse format + d = isMySQL || isPostgres ? dayjs(textToCopy, 'HH:mm:ss') : dayjs(textToCopy) + } if (!d.isValid()) { // return empty string for invalid time