From 008902f01fb4bd5f1b9da9d4f20a4f42e578c8a9 Mon Sep 17 00:00:00 2001 From: SheenaMalhotra182 Date: Fri, 22 Sep 2023 22:08:56 +0530 Subject: [PATCH] [ACS-5857] fixed date parsing and linting --- .../src/lib/form/components/widgets/date/date.widget.ts | 6 ++---- .../lib/form/components/widgets/date/date-cloud.widget.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/core/src/lib/form/components/widgets/date/date.widget.ts b/lib/core/src/lib/form/components/widgets/date/date.widget.ts index 9abe395767..dd49894895 100644 --- a/lib/core/src/lib/form/components/widgets/date/date.widget.ts +++ b/lib/core/src/lib/form/components/widgets/date/date.widget.ts @@ -24,9 +24,7 @@ import { FormService } from '../../../services/form.service'; import { WidgetComponent } from '../widget.component'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import { DateFnsAdapter, - MAT_DATE_FNS_FORMATS -} from '@angular/material-date-fns-adapter'; +import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter'; import { DateFnsUtils } from '../../../../common/utils/date-fns-utils'; import { isValid } from 'date-fns'; import { DateFormatTranslationService } from '../../../services/date-format-translation.service'; @@ -89,7 +87,7 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDe } onDateChanged(newDateValue) { - const date = new Date(newDateValue); + const date = this.dateFormatTranslationService.parse(newDateValue, this.field.dateDisplayFormat, new Date()); if (isValid(date)) { this.field.value = this.dateFormatTranslationService.format(date, this.field.dateDisplayFormat); } else { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts index a8a9d292bd..10fd714b6b 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts @@ -102,7 +102,7 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, } onDateChanged(newDateValue) { - const date = new Date(newDateValue); + const date = this.dateFormatTranslationService.parse(newDateValue, this.field.dateDisplayFormat, new Date()); if (isValid(date)) { this.field.value = this.dateFormatTranslationService.format(date, this.field.dateDisplayFormat); } else {