Merge pull request #2741 from AnvayKharb/WEB-389-editing-existing-holidays-fails-due-to-date-format-problem

WEB-389: Fix date format issue when editing holidays
This commit is contained in:
Gopi Kishan
2025-11-20 02:36:13 +05:30
committed by GitHub
2 changed files with 18 additions and 12 deletions
@@ -332,11 +332,14 @@ export class CreateHolidayComponent implements OnInit {
const locale = this.settings.language.code; const locale = this.settings.language.code;
const prevFromDate: Date = this.holidayForm.value.fromDate; const prevFromDate: Date = this.holidayForm.value.fromDate;
const prevToDate: Date = this.holidayForm.value.toDate; const prevToDate: Date = this.holidayForm.value.toDate;
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
if (this.holidayForm.contains('repaymentsRescheduledTo')) { if (this.holidayForm.contains('repaymentsRescheduledTo')) {
const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat); holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(
prevRepaymentsRescheduledTo,
dateFormat
);
} }
const offices = this.holidayForm.value.offices.map((office: string) => { const offices = this.holidayForm.value.offices.map((office: string) => {
return { officeId: Number.parseInt(office, 10) }; return { officeId: Number.parseInt(office, 10) };
@@ -134,17 +134,20 @@ export class EditHolidayComponent implements OnInit {
const locale = this.settingsService.language.code; const locale = this.settingsService.language.code;
const dateFormat = this.settingsService.dateFormat; const dateFormat = this.settingsService.dateFormat;
if (!this.isActiveHoliday) { if (!this.isActiveHoliday) {
if (holidayFormData.fromDate instanceof Date) { const prevFromDate = this.holidayForm.value.fromDate;
holidayFormData.fromDate = this.dateUtils.formatDate(holidayFormData.fromDate, dateFormat); const prevToDate = this.holidayForm.value.toDate;
if (prevFromDate instanceof Date) {
holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
} }
if (holidayFormData.toDate instanceof Date) { if (prevToDate instanceof Date) {
holidayFormData.toDate = this.dateUtils.formatDate(holidayFormData.toDate, dateFormat); holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
} }
if (this.reSchedulingType === 2 && holidayFormData.repaymentsRescheduledTo instanceof Date) { if (this.reSchedulingType === 2) {
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate( const repaymentScheduledTo = this.holidayForm.value.repaymentsRescheduledTo;
holidayFormData.repaymentsRescheduledTo, if (repaymentScheduledTo instanceof Date) {
dateFormat holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(repaymentScheduledTo, dateFormat);
); }
} }
} }
const data = { const data = {