From f41a090f8f09eaf9285216130d7f05475dc0d2e3 Mon Sep 17 00:00:00 2001 From: SheenaMalhotra182 Date: Tue, 10 Oct 2023 00:22:21 +0530 Subject: [PATCH] [ACS-5857] reverted date field back to moment in form-field-model.ts --- .../lib/form/components/widgets/core/form-field.model.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts index dccde63942..bf9e8944db 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts @@ -434,13 +434,12 @@ export class FormFieldModel extends FormWidgetModel { } case FormFieldTypes.DATE: { if (typeof this.value === 'string' && this.value === 'today') { - this.value = DateFnsUtils.formatDate(new Date(), this.dateDisplayFormat); + this.value = moment(new Date()).format(this.dateDisplayFormat); } - const dateValue = DateFnsUtils.parseDate(this.value, this.dateDisplayFormat); - - if (isValid(dateValue)) { - this.form.values[this.id] = `${DateFnsUtils.formatDate(dateValue, 'YYYY-MM-DD')}T00:00:00.000Z`; + const dateValue = moment(this.value, this.dateDisplayFormat, true); + if (dateValue?.isValid()) { + this.form.values[this.id] = `${dateValue.format('YYYY-MM-DD')}T00:00:00.000Z`; } else { this.form.values[this.id] = null; this._value = this.value;