From f3c92ad1cfc6b430b08b608a418882015a33e5aa Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 2 May 2023 16:36:41 +0800 Subject: [PATCH] fix(nocodb): handle copy n paste datetime --- packages/nocodb-nest/src/models/Model.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nocodb-nest/src/models/Model.ts b/packages/nocodb-nest/src/models/Model.ts index ca5013c9d7..40c7d98146 100644 --- a/packages/nocodb-nest/src/models/Model.ts +++ b/packages/nocodb-nest/src/models/Model.ts @@ -458,8 +458,11 @@ export default class Model implements TableType { if (isMySQL) { if (val.slice(-1) === 'Z') { // from UI + // e.g. 2023-05-02 08:09:43Z val = dayjs(val).format('YYYY-MM-DD HH:mm:ss'); } else { + // from API + // e.g. 2021-01-01 04:00:00+04:00 val = dayjs .utc(val) .utcOffset(d.getTimezoneOffset(), true) @@ -467,7 +470,7 @@ export default class Model implements TableType { } } else if (isSqlite) { let keepLocalTime = false; - if (val.slice(-1) === 'Z') { + if (val.slice(-1) === 'Z' || val.slice(-6) === '+00:00') { // from UI keepLocalTime = true; } @@ -477,7 +480,7 @@ export default class Model implements TableType { .format('YYYY-MM-DD HH:mm:ss'); } else { let keepLocalTime = false; - if (val.slice(-1) === 'Z') { + if (val.slice(-1) === 'Z' || val.slice(-6) === '+00:00') { // from UI keepLocalTime = true; }