Browse Source

fix(nocodb): sqlite logic datetime display logic

pull/5659/head
Wing-Kam Wong 2 years ago
parent
commit
6cca3b0ce1
  1. 25
      packages/nocodb/src/db/BaseModelSqlv2.ts

25
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3301,19 +3301,30 @@ class BaseModelSqlv2 {
if (d) {
for (const col of dateTimeColumns) {
if (d[col.title]) {
let keepLocalTime = true;
if (this.isSqlite) {
if (!col.cdf && !isXcdbBase) {
if (d[col.title].indexOf('+') > -1) {
// e.g. 2023-05-10 10:25:45+00:00
// timezone already attached to input
// hence, skip it
if (!col.cdf) {
if (
d[col.title].indexOf('+') === -1 &&
d[col.title].slice(-1) !== 'Z'
) {
// if there is no timezone info,
// we assume the input is on NocoDB server timezone
// then we convert to UTC from server timezone
// e.g. 2023-04-27 10:00:00 (IST) -> 2023-04-27 04:30:00+00:00
d[col.title] = dayjs(d[col.title])
.tz(Intl.DateTimeFormat().resolvedOptions().timeZone)
.utc()
.format('YYYY-MM-DD HH:mm:ssZ');
continue;
} else {
// otherwise, we convert from the given timezone to UTC
keepLocalTime = false;
}
}
}
let keepLocalTime = true;
if (this.isPg && col.dt === 'timestamp with time zone') {
// postgres - timezone already attached to input
// e.g. 2023-05-11 16:16:51+08:00

Loading…
Cancel
Save