Skip to content

Commit

Permalink
Bugfix KNOWAGE-8571
Browse files Browse the repository at this point in the history
  • Loading branch information
BojanSovticEngIT committed Aug 6, 2024
1 parent 37bb48c commit b1ed0f0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ const removeEmptyToolbarItems = (toolbarMenuItems: any[]) => {
export const getValidDate = (value: string, serverDateFormat: string) => {
const extractedDateValue = extractDatePart(value)
let momentDate = moment(deepcopy(extractedDateValue))
const tempServerDateFormat = serverDateFormat.replaceAll('y', 'Y')
const tempServerDateFormat = convertToMomentFormat(serverDateFormat)
const validFormats = [tempServerDateFormat, 'DD/MM/YYYY', 'DD/MM/YYYY HH:mm:ss.SSS']
let tempDateFormatFromTheDateValue = extractDateFormatPart(value)
if (tempDateFormatFromTheDateValue) {
tempDateFormatFromTheDateValue = tempDateFormatFromTheDateValue.replaceAll('y', 'Y')
tempDateFormatFromTheDateValue = convertToMomentFormat(tempDateFormatFromTheDateValue)
validFormats.unshift(tempDateFormatFromTheDateValue)
}
for (let i = 0; i < validFormats.length; i++) {
Expand All @@ -140,6 +140,10 @@ export const getValidDate = (value: string, serverDateFormat: string) => {
return ''
}

const convertToMomentFormat = (format: string) => {
return format.replace(/yyyy/g, 'YYYY').replace(/dd/g, 'DD').replace(/mm/g, 'MM')
}

const extractDatePart = (dateString: string) => {
if (dateString.includes('#')) {
return dateString.split('#')[0]
Expand Down

0 comments on commit b1ed0f0

Please sign in to comment.