diff --git a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue index dd5c78366..8fe81c067 100644 --- a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue +++ b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue @@ -123,6 +123,7 @@ import Dropdown from 'primevue/dropdown' import QBEFilterDialogDescriptor from './QBEFilterDialogDescriptor.json' import QBEFilterValuesTable from './QBEFilterValuesTable.vue' import moment from 'moment' +import { getLocale, localeDate } from '@/helpers/commons/localeHelper' export default defineComponent({ name: 'qbe-filter-card', @@ -309,9 +310,23 @@ export default defineComponent({ }, onManualValueChange() { if (this.filter) { + const isDateOrTimestamp = ['DATE', 'TIMESTAMP'].includes(this.field?.id?.type) + if (isDateOrTimestamp) this.formatManualDate() this.filter.rightOperandValue = [this.filter.rightOperandDescription] } }, + formatManualDate() { + if (!this.filter) return + + const serverFormat = 'DD/MM/YYYY hh:mm' + const format = localeDate().replace(/yyyy/g, 'YYYY').replace(/dd/g, 'DD').replace(/d/g, 'D').replace(/MM/g, 'MM').replace(/M/g, 'M').replace(/hh/g, 'HH').replace(/mm/g, 'mm').replace(/ss/g, 'ss').replace(/SSS/g, 'SSS') + const momentDate = moment(this.filter.rightOperandDescription, format, true) + + if (momentDate.isValid()) { + const formattedDate = momentDate.format(serverFormat) + this.filter.rightOperandDescription = formattedDate + } + }, onManualBetweenChange() { if (this.filter) { this.filter.rightOperandValue = [this.firstOperand, this.secondOperand]