gbif / parsers

Various GBIF parsers for dates, countries, language, taxon ranks, etc
Apache License 2.0
4 stars 8 forks source link

Parsing an ambiguous date, e.g. 1/2/2000 with a configurable parser #24

Closed qifeng-bai closed 4 years ago

qifeng-bai commented 4 years ago

Original issue is here: https://github.com/AtlasOfLivingAustralia/la-pipelines/issues/89

When TemporalInterpreter. interpretTemporal() is parsing DwcTerm.dateIdentified It can parse: 12/12/2012 , 12/13/2012, 11/DEC/2012.,

but failed without any assertion on 11/12/2012

Solution: GBIF.org will continue (by default) to recognize only ISO dates, or unambiguous d/m/y m/d/y dates. By configuration, date parser can choose given formats, like EU or US to parse the ambiguous date

qifeng-bai commented 4 years ago

I created a new branch https://github.com/gbif/parsers/tree/24_eu_us_date for discussion Added a new method: parse(String input, DateFormatHint[] ambiguous_hints)

When the standard parsing process find an ambiguous date, like 2/3/2000, try @param ambiguous_hints to parse date, and return the first succeeded result

qifeng-bai commented 4 years ago

https://github.com/gbif/parsers/pull/25