Skip to content

Commit 73904b5

Browse files
Global format config. Implementation for dateFormat, dateTimeFormat, NumberFormat
1 parent dbd3064 commit 73904b5

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

  • packages/devextreme/js/__internal/grids

packages/devextreme/js/__internal/grids/grid_core/m_utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ const getGlobalFormat = (dataType) => {
9393
}
9494

9595
return isString(globalFormat)
96-
? (value) => dateLocalization.format(value, globalFormat)
96+
? (value) => {
97+
const dateValue = value instanceof Date ? value : new Date(value);
98+
return isNaN(dateValue.getTime()) ? '' : dateLocalization.format(dateValue, globalFormat);
99+
}
97100
: globalFormat;
98101
};
99102

packages/devextreme/js/__internal/grids/new/grid_core/columns_controller/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,13 @@ const getGlobalFormat = (
235235

236236
if (isString(globalFormat)) {
237237
return (
238-
(value: Date) => dateLocalization.format(value, globalFormat) as string
238+
(value: Date | string | number) => {
239+
const dateValue = value instanceof Date ? value : new Date(value);
240+
241+
return isNaN(dateValue.getTime())
242+
? ''
243+
: dateLocalization.format(dateValue, globalFormat) as string;
244+
}
239245
) as unknown as Format;
240246
}
241247

0 commit comments

Comments
 (0)