1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

parsing a short year format with date-fns?

Discussão em 'Angular' iniciado por stax, Outubro 7, 2024.

  1. stax

    stax Guest

    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"
    },
    };

    Continue reading...

Compartilhe esta Página