|
|
@ -7,6 +7,7 @@ import { nocoExecute } from 'nc-help'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
AuditOperationSubTypes, |
|
|
|
AuditOperationSubTypes, |
|
|
|
AuditOperationTypes, |
|
|
|
AuditOperationTypes, |
|
|
|
|
|
|
|
BoolType, |
|
|
|
isSystemColumn, |
|
|
|
isSystemColumn, |
|
|
|
isVirtualCol, |
|
|
|
isVirtualCol, |
|
|
|
RelationTypes, |
|
|
|
RelationTypes, |
|
|
@ -3169,9 +3170,8 @@ class BaseModelSqlv2 { |
|
|
|
data = this.convertAttachmentType(data, childTable); |
|
|
|
data = this.convertAttachmentType(data, childTable); |
|
|
|
|
|
|
|
|
|
|
|
// update date time fields
|
|
|
|
// update date time fields
|
|
|
|
if (this.isMySQL && !(await this.isXcdbBase())) { |
|
|
|
const isXcdbBase = await this.isXcdbBase(); |
|
|
|
data = this.convertDateFormat(data, childTable); |
|
|
|
data = this.convertDateFormat(data, isXcdbBase, childTable); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
@ -3215,23 +3215,35 @@ class BaseModelSqlv2 { |
|
|
|
private _convertDateFormat( |
|
|
|
private _convertDateFormat( |
|
|
|
dateTimeColumns: Record<string, any>[], |
|
|
|
dateTimeColumns: Record<string, any>[], |
|
|
|
d: Record<string, any>, |
|
|
|
d: Record<string, any>, |
|
|
|
|
|
|
|
isXcdbBase: BoolType, |
|
|
|
) { |
|
|
|
) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (d) { |
|
|
|
if (d) { |
|
|
|
dateTimeColumns.forEach((col) => { |
|
|
|
dateTimeColumns.forEach((col) => { |
|
|
|
if (d[col.title] && typeof d[col.title] === 'string') { |
|
|
|
if (d[col.title] && typeof d[col.title] === 'string') { |
|
|
|
// e.g. 2022-01-01 04:30:00+00:00
|
|
|
|
if (isXcdbBase) { |
|
|
|
|
|
|
|
// e.g. 01.01.2022 10:00:00+05:30 -> 2022-01-01 04:30:00+00:00
|
|
|
|
|
|
|
|
d[col.title] = dayjs(d[col.title]) |
|
|
|
|
|
|
|
.utc(true) |
|
|
|
|
|
|
|
.format('YYYY-MM-DD HH:mm:ssZ'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// e.g. 01.01.2022 10:00:00+05:30 -> 2022-01-01 04:30:00+00:00
|
|
|
|
d[col.title] = dayjs(d[col.title]) |
|
|
|
d[col.title] = dayjs(d[col.title]) |
|
|
|
.utc() |
|
|
|
.utc() |
|
|
|
.format('YYYY-MM-DD HH:mm:ssZ'); |
|
|
|
.format('YYYY-MM-DD HH:mm:ssZ'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch {} |
|
|
|
} catch {} |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private convertDateFormat(data: Record<string, any>, childTable?: Model) { |
|
|
|
private convertDateFormat( |
|
|
|
|
|
|
|
data: Record<string, any>, |
|
|
|
|
|
|
|
isXcdbBase: BoolType, |
|
|
|
|
|
|
|
childTable?: Model, |
|
|
|
|
|
|
|
) { |
|
|
|
// MySQL converts TIMESTAMP values from the current time zone to UTC for storage.
|
|
|
|
// MySQL converts TIMESTAMP values from the current time zone to UTC for storage.
|
|
|
|
// Then, MySQL converts those values back from UTC to the current time zone for retrieval.
|
|
|
|
// Then, MySQL converts those values back from UTC to the current time zone for retrieval.
|
|
|
|
// For xcdb base, to make it consistent with other DB types, we show the result in UTC instead
|
|
|
|
// For xcdb base, to make it consistent with other DB types, we show the result in UTC instead
|
|
|
@ -3242,9 +3254,11 @@ class BaseModelSqlv2 { |
|
|
|
).filter((c) => c.uidt === UITypes.DateTime); |
|
|
|
).filter((c) => c.uidt === UITypes.DateTime); |
|
|
|
if (dateTimeColumns.length) { |
|
|
|
if (dateTimeColumns.length) { |
|
|
|
if (Array.isArray(data)) { |
|
|
|
if (Array.isArray(data)) { |
|
|
|
data = data.map((d) => this._convertDateFormat(dateTimeColumns, d)); |
|
|
|
data = data.map((d) => |
|
|
|
|
|
|
|
this._convertDateFormat(dateTimeColumns, d, isXcdbBase), |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this._convertDateFormat(dateTimeColumns, data); |
|
|
|
this._convertDateFormat(dateTimeColumns, data, isXcdbBase); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|