Browse Source

fix(nocodb): handle copy n paste datetime

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
f3c92ad1cf
  1. 7
      packages/nocodb-nest/src/models/Model.ts

7
packages/nocodb-nest/src/models/Model.ts

@ -458,8 +458,11 @@ export default class Model implements TableType {
if (isMySQL) { if (isMySQL) {
if (val.slice(-1) === 'Z') { if (val.slice(-1) === 'Z') {
// from UI // from UI
// e.g. 2023-05-02 08:09:43Z
val = dayjs(val).format('YYYY-MM-DD HH:mm:ss'); val = dayjs(val).format('YYYY-MM-DD HH:mm:ss');
} else { } else {
// from API
// e.g. 2021-01-01 04:00:00+04:00
val = dayjs val = dayjs
.utc(val) .utc(val)
.utcOffset(d.getTimezoneOffset(), true) .utcOffset(d.getTimezoneOffset(), true)
@ -467,7 +470,7 @@ export default class Model implements TableType {
} }
} else if (isSqlite) { } else if (isSqlite) {
let keepLocalTime = false; let keepLocalTime = false;
if (val.slice(-1) === 'Z') { if (val.slice(-1) === 'Z' || val.slice(-6) === '+00:00') {
// from UI // from UI
keepLocalTime = true; keepLocalTime = true;
} }
@ -477,7 +480,7 @@ export default class Model implements TableType {
.format('YYYY-MM-DD HH:mm:ss'); .format('YYYY-MM-DD HH:mm:ss');
} else { } else {
let keepLocalTime = false; let keepLocalTime = false;
if (val.slice(-1) === 'Z') { if (val.slice(-1) === 'Z' || val.slice(-6) === '+00:00') {
// from UI // from UI
keepLocalTime = true; keepLocalTime = true;
} }

Loading…
Cancel
Save