From 11e27ca4989e986d2134f4fe3795152b5dba9d67 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 6 May 2023 13:24:41 +0800 Subject: [PATCH] fix(nc-gui): revise paste datetime logic --- .../useMultiSelect/convertCellData.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useMultiSelect/convertCellData.ts b/packages/nc-gui/composables/useMultiSelect/convertCellData.ts index 2e2fea3fbf..5804107d09 100644 --- a/packages/nc-gui/composables/useMultiSelect/convertCellData.ts +++ b/packages/nc-gui/composables/useMultiSelect/convertCellData.ts @@ -47,12 +47,22 @@ export default function convertCellData( } if (isXcdbBase) { if (isMysql) { - // UTC + 'Z' - return `${parsedDateTime.format('YYYY-MM-DD HH:mm:ss')}Z` + let res = `${parsedDateTime.format('YYYY-MM-DD HH:mm:ss')}` + if (!dayjs.isDayjs(value)) { + // UTC + 'Z' + res += 'Z' + } + return res } else if (isMssql) { return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ') } else { - return parsedDateTime.utc(true).format('YYYY-MM-DD HH:mm:ssZ') + if (!dayjs.isDayjs(value)) { + // e.g. copy the existing cell - 2023-05-06 13:06:51 (UTC) + return parsedDateTime.utc(true).format('YYYY-MM-DD HH:mm:ssZ') + } + // e.g. copy right after setting by datepicker + // value includes timezone + return parsedDateTime } } // TODO(timezone): keep ext db as it is