Skip to content

String does not match format DDMMMYY #668

Open

Description

@gitfran

Hi,

"String does not match format DDMMMYY" this happens for example when the date is 14NOV22 or 14nov22, and it works only when the first letter of the month is in uppercase 14Nov22.

It would be greate if it works in all those cases.

Thanks!

Activity

  1. tudopropaganda commented on Apr 14, 2025

    @tudopropaganda

    You should use strict=False

    print(pendulum.parse("14nov22", strict=False))
    2014-11-22 00:00:00+00:00
  2. Alox1d commented on Oct 15, 2026

    @Alox1d

    The strict=False example above is not an equivalent workaround: it returns 2014-11-22, whereas DDMMMYY for 14nov22 means 2022-11-14. That fallback goes through dateutil and its date-order preferences, rather than preserving the supplied format contract.

    The current formatter has two relevant layers: _replace_tokens() builds case-sensitive month alternatives, and Locale.match_translation() performs an exact-value lookup. Making only the regex case-insensitive would leave the second layer unmatched; normalize the captured month and lookup candidates consistently as well. Keeping this scoped to month tokens also avoids accidentally changing escaped literal matching.

    Suggested regression table: 14Nov22, 14NOV22, and 14nov22 with DDMMMYY, all asserting year 2022, month 11, day 14; repeat with DDMMMYYYY and reject an unknown month. Asserting the full date catches the misleading fallback result.

    I maintain DateParser Kotlin; its MIT English month grammar is a case-normalization reference, not a Python dependency. I haven't run Pendulum's tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions