Skip to content

%Y should return an error when parsing a non-4 digit year #332

@matiu2

Description

@matiu2

Currently parsing a year like 19 with %Y will return 0019.

It should return an error because the year doesn't have 4 digits.

Users should use %y (lowercase) for 2 digit years and %Y for 4 digit years.


Use case:

I hit this bug while porting a program from python, where it tries to parse the date in different formats in order (to clean up dirty data).

The input is: 30-09-19 (and we expect the format %Y-%m-%d to fail, and later on the format: %d-%m-%y to catch it) (It should September 30th 2019).

In the rust version I'll have to either check that the year is not too far in the future, or re-arrange the order that we check the different formats in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions