diff --git a/src/modules/documentExecution/main/DocumentExecutionHelpers.ts b/src/modules/documentExecution/main/DocumentExecutionHelpers.ts index aa2554d44..a51233988 100644 --- a/src/modules/documentExecution/main/DocumentExecutionHelpers.ts +++ b/src/modules/documentExecution/main/DocumentExecutionHelpers.ts @@ -126,8 +126,13 @@ const removeEmptyToolbarItems = (toolbarMenuItems: any[]) => { export const getValidDate = (value: string, serverDateFormat: string) => { const extractedDateValue = extractDatePart(value) let momentDate = moment(deepcopy(extractedDateValue)) - const tempServerDateFormat = serverDateFormat === 'yyyy-MM-dd' ? 'YYYY-MM-DD' : serverDateFormat + const tempServerDateFormat = serverDateFormat.replaceAll('y', 'Y') const validFormats = [tempServerDateFormat, 'DD/MM/YYYY', 'DD/MM/YYYY HH:mm:ss.SSS'] + let tempDateFormatFromTheDateValue = extractDateFormatPart(value) + if (tempDateFormatFromTheDateValue) { + tempDateFormatFromTheDateValue = tempDateFormatFromTheDateValue.replaceAll('y', 'Y') + validFormats.unshift(tempDateFormatFromTheDateValue) + } for (let i = 0; i < validFormats.length; i++) { momentDate = moment(deepcopy(extractedDateValue), validFormats[i]) if (momentDate.isValid()) return momentDate.toDate() @@ -141,3 +146,10 @@ const extractDatePart = (dateString: string) => { } return dateString } + +const extractDateFormatPart = (dateString: string) => { + if (dateString.includes('#')) { + return dateString.split('#')[1] + } + return dateString +}