diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index 1b0365b1a..47f35c0ce 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -299,11 +299,22 @@ const DATE_FORMATS = [ 'dd.MM.yyyy', 'yyyy-MM-dd', 'yyyy.MM.dd', - 'yyyy/MM/dd' + 'yyyy/MM/dd', + 'yyyyMMdd' ]; // Helper function to parse a date string export function parseDate(date: string): Date | null { + // Transform 'yyyyMMdd' format to supported format by parse function + if (`${date}`.length == 8) { + date = date.toString(); + const match = date.match(/^(\d{4})(\d{2})(\d{2})$/); + if (match) { + const [, year, month, day] = match; + date = `${year}-${month}-${day}`; + } + } + const matchingFormat = DATE_FORMATS.find( (format) => isMatch(date, format) && date.length === format.length );