akoumjian / datefinder

Find dates inside text using Python and get back datetime objects
http://datefinder.readthedocs.org/en/latest/
MIT License
635 stars 165 forks source link

Broken in 0.7.3 : date not detected with specific surrounding text #178

Open stevendavis opened 2 years ago

stevendavis commented 2 years ago

These test cases pass with version 0.7.1 and fail with version 0.7.3

    line = "as of June 30, 2019. Management"
    assert list(find_dates(line)) == [datetime.datetime(2019, 6, 30)]

    line = "As of November 30, 2020, management"
    assert list(find_dates(line)) == [datetime.datetime(2020, 11, 30)]

These test cases pass with both version 0.7.1 and 0.7.3

    line = "As of June 30, 2019, the"
    assert list(find_dates(line)) == [datetime.datetime(2019, 6, 30)]

    line = "outstanding as of November 30, 2020, is"
    assert list(find_dates(line)) == [datetime.datetime(2020, 11, 30)]
NathanSmeltzer commented 1 year ago

I'm experience the same issue.

These strings return an empty generator: "Your item departed our USPS facility in HARRISBURG, PA 17112 on December 22, 2022 at 5:58 am." "17112 on December 22, 2022 at 5:58 am"

This returns the incorrect year: "7112 on December 22, 2022 at 5:58 am"

It only works when shortening the string and removing any other numbers: "on December 22, 2022 at 5:58 am"