|
|
@ -3215,19 +3215,19 @@ class BaseModelSqlv2 { |
|
|
|
dateTimeColumns: Record<string, any>[], |
|
|
|
dateTimeColumns: Record<string, any>[], |
|
|
|
d: Record<string, any>, |
|
|
|
d: Record<string, any>, |
|
|
|
) { |
|
|
|
) { |
|
|
|
try { |
|
|
|
|
|
|
|
if (d) { |
|
|
|
if (d) { |
|
|
|
dateTimeColumns.forEach((col) => { |
|
|
|
dateTimeColumns.forEach((col) => { |
|
|
|
if (d[col.title]) { |
|
|
|
if (d[col.title]) { |
|
|
|
// e.g. 01.01.2022 10:00:00+05:30 -> 2022-01-01 04:30:00+00:00
|
|
|
|
// e.g. 01.01.2022 10:00:00+05:30 -> 2022-01-01 04:30:00+00:00
|
|
|
|
// e.g. 2023-05-09 11:41:49 -> 2023-05-09 11:41:49+00:00
|
|
|
|
// e.g. 2023-05-09 11:41:49 -> 2023-05-09 11:41:49+00:00
|
|
|
|
d[col.title] = dayjs(d[col.title]) |
|
|
|
d[col.title] = dayjs(d[col.title]) |
|
|
|
|
|
|
|
// keep the local time
|
|
|
|
.utc(true) |
|
|
|
.utc(true) |
|
|
|
|
|
|
|
// show the timezone even for Mysql
|
|
|
|
.format('YYYY-MM-DD HH:mm:ssZ'); |
|
|
|
.format('YYYY-MM-DD HH:mm:ssZ'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch {} |
|
|
|
|
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3249,6 +3249,9 @@ class BaseModelSqlv2 { |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SET TIME ZONE only works for the current session
|
|
|
|
|
|
|
|
// trigger before insert / update
|
|
|
|
|
|
|
|
// TODO: refactor - maybe there is a better approach
|
|
|
|
private async setUtcTimezoneForPg() { |
|
|
|
private async setUtcTimezoneForPg() { |
|
|
|
if (this.isPg && (await this.isXcdbBase())) { |
|
|
|
if (this.isPg && (await this.isXcdbBase())) { |
|
|
|
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`); |
|
|
|
await this.dbDriver.raw(`SET TIME ZONE 'UTC'`); |
|
|
|