|
|
@ -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 |
|
|
|
); |
|
|
|