sisyphsu / dateparser

dateparser is a smart and high-performance date parser library, it supports hundreds of different formats, nearly all format that we may used. And this is also a showcase for "retree" algorithm.
MIT License
95 stars 23 forks source link

Missing date format #7

Closed keren42 closed 3 years ago

keren42 commented 4 years ago

Hi,

The following format throws an exception:

2020-30-03T18:28:47.382Z

I tried to add a customized rule: DateParser parser = DateParser.newBuilder().addRule("(?\d{4})\W{1}(?\d{1,2})\W{1}(?\d{1,2})[^\d]?(?\d{1,2}):(?\d{1,2})(?:(?\d{1,2}))?(?:.,)?(?z)?").build();

But it didn't work. What am I doing wrong?

I need to support both YYYY-mm-dd and YYYY-dd-mm.

Thank you.

sisyphsu commented 4 years ago

I think DateParser cannot support mm-dd and dd-mm at the same time.

For example, 07-11 can represent July.11, or Nov.7, It's too confused to recognize it.

Also, it seems that nobody use YYYY-dd-mm in the world, why support it?

https://stackoverflow.com/questions/2254014/are-there-locales-or-common-programs-that-use-yyyy-dd-mm-as-the-date-format#:~:text=yyyy%2Dmm%2Ddd%20in%20particular,month%2C%20julian%20day%2C%20etc.