Browse Source

feat(nocodb): handle date month in API response

pull/6870/head
աɨռɢӄաօռɢ 1 year ago
parent
commit
e4ad0eb3d5
  1. 13
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -9,6 +9,7 @@ import { nocoExecute } from 'nc-help';
import { import {
AuditOperationSubTypes, AuditOperationSubTypes,
AuditOperationTypes, AuditOperationTypes,
isDateMonthFormat,
isLinksOrLTAR, isLinksOrLTAR,
isSystemColumn, isSystemColumn,
isVirtualCol, isVirtualCol,
@ -4279,6 +4280,13 @@ class BaseModelSqlv2 {
continue; continue;
} }
if (col.uidt === UITypes.Date) {
const dateFormat = col.meta.date_format;
if (isDateMonthFormat(dateFormat)) {
d[col.title] = dayjs(d[col.title], dateFormat).format(dateFormat);
}
continue;
}
let keepLocalTime = true; let keepLocalTime = true;
if (this.isSqlite) { if (this.isSqlite) {
@ -4336,7 +4344,10 @@ class BaseModelSqlv2 {
const dateTimeColumns = ( const dateTimeColumns = (
childTable ? childTable.columns : this.model.columns childTable ? childTable.columns : this.model.columns
).filter( ).filter(
(c) => c.uidt === UITypes.DateTime || c.uidt === UITypes.Formula, (c) =>
c.uidt === UITypes.DateTime ||
c.uidt === UITypes.Date ||
c.uidt === UITypes.Formula,
); );
if (dateTimeColumns.length) { if (dateTimeColumns.length) {
if (Array.isArray(data)) { if (Array.isArray(data)) {

Loading…
Cancel
Save