Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/inputs/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ const LOADING_STATUS_MAPPING = {
};

const _formatMinMaxDatesInColumns = (col, dateFormat) => {
if (col.type && col.type.indexOf('date') !== -1) {
if (col.minValue) {
col.minValue = DateUtils.format(new Date(col.minValue), dateFormat) || col.minValue;
}
if (col.maxValue) {
col.maxValue = DateUtils.format(new Date(col.maxValue), dateFormat) || col.maxValue;
const formatValueIfNecessary = (value, dateFormat) => {
if (DateUtils.isValid(value, dateFormat)) return value;
if (DateUtils.isValidDate(value)) return DateUtils.format(value, dateFormat);
try {
// Fall back to default Date constructor & format to expected dateFormat
return DateUtils.format(new Date(value), dateFormat);
} catch (error) {
console.error(error);
}
};

if (col.type && col.type.indexOf('date') !== -1) {
if (col.minValue) col.minValue = formatValueIfNecessary(col.minValue, dateFormat);
if (col.maxValue) col.maxValue = formatValueIfNecessary(col.maxValue, dateFormat);
}
};

Expand Down
Loading