How can I use the Date-Fns Adapter for Angular Material to parse short date formats without an explicit separator? For example, 010123 => 01.01.2023. With the whole year it works as expected: 01012023 => 01.01.2023
My actual thought process would be ddMMyy but according to the Unicode Documentation:
However, "yy" requests just the two low-order digits of the year, zero-padded as necessary.
So the Unicode tokens would reference the year 0023 instead of 2023.
My question is how can I adjust this context to get this desired behavior?
Here is my CUSTOM_FORMAT:
export const CUSTOM_FORMAT: MatDateFormats = {
parse: {
dateInput: ["dd.MM.yyyy", "dd/MM/yyyy", "dd,MM,yyyy", "ddMMyyyy", "ddMMyy"],
},
display: {
dateInput: "dd.MM.yyyy",
monthYearLabel: "MMM yyyy",
dateA11yLabel: "MMMM d, y",
monthYearA11yLabel: "MMM yyyy"
},
};
I fixed my problem by writing a CustomDateAdapter that overrides the default parse function of the DateFnsAdapter.
In my CustomDateAdapter: