From 284538aa9313c9eafd6b28665699a7b98c8cad9c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 11 May 2023 18:39:37 +0800 Subject: [PATCH] fix(nocodb): sqlite write date time logic (ext db) --- packages/nocodb/src/models/Model.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index bb30adbf44..6f2bc4ebc8 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -527,6 +527,20 @@ export default class Model implements TableType { val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'); } } + } else if (isSqlite) { + if (val.slice(-1) === 'Z') { + // from UI + val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'); + } else { + // from API + if (val.indexOf('+') === -1) { + // no timezone info - considered as UTC + val = dayjs(val).utc(true).format('YYYY-MM-DD HH:mm:ssZ'); + } else { + // timezone info found - convert to UTC + val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'); + } + } } else { val = dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'); }