Browse Source

fix(nocodb): multiple datetimes in formula

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
66669b117d
  1. 17
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -3263,14 +3263,15 @@ class BaseModelSqlv2 {
for (const col of dateTimeColumns) { for (const col of dateTimeColumns) {
if (d[col.title]) { if (d[col.title]) {
if (col.uidt === UITypes.Formula) { if (col.uidt === UITypes.Formula) {
if (dayjs(d[col.title]).isValid()) { d[col.title] = d[col.title].replace(
// d[col.title] will be in UTC without timezone /\b(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\b/g,
// append the timezone info here (match) => {
// e.g. 2021-12-30 04:00:00 -> 2021-12-30 04:00:00+00:00 // d[col.title] will be in UTC without timezone
d[col.title] = dayjs(d[col.title]) // append the timezone info here
.utc(true) // e.g. 2021-12-30 04:00:00 -> 2021-12-30 04:00:00+00:00
.format('YYYY-MM-DD HH:mm:ssZ'); return dayjs(match).utc(true).format('YYYY-MM-DD HH:mm:ssZ');
} },
);
continue; continue;
} }

Loading…
Cancel
Save