diff --git a/dateparser/data/date_translation_data/en.py b/dateparser/data/date_translation_data/en.py index 017edb218..2eb5052ae 100644 --- a/dateparser/data/date_translation_data/en.py +++ b/dateparser/data/date_translation_data/en.py @@ -1191,6 +1191,9 @@ { "from\\s+now": "in" }, + { + "(\\d+(?:st|nd|rd|th)?) of the month": "\\1 of this month" + }, { "less than 1 minute ago": "45 second ago" }, diff --git a/dateparser_data/supplementary_language_data/date_translation_data/en.yaml b/dateparser_data/supplementary_language_data/date_translation_data/en.yaml index 624128e04..c3b94ccfd 100644 --- a/dateparser_data/supplementary_language_data/date_translation_data/en.yaml +++ b/dateparser_data/supplementary_language_data/date_translation_data/en.yaml @@ -109,6 +109,7 @@ simplifications: - in the ((?:early )?morning|afternoon|evening|night|small hours|wee hours): \1 - (\d+[.,]?\d*)h(\d+[.,]?\d*): \1:\2 - from\s+now: in + - (\d+(?:st|nd|rd|th)?) of the month: \1 of this month - less than 1 minute ago: 45 second ago - (\d+(?:st|nd|rd|th)) day: \1 - (\d+[.,]?\d*|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve) (decade|year|month|week|day|hour|minute|second)s? later: in \1 \2 diff --git a/tests/test_freshness_date_parser.py b/tests/test_freshness_date_parser.py index c6a596ac4..7560e7f2e 100644 --- a/tests/test_freshness_date_parser.py +++ b/tests/test_freshness_date_parser.py @@ -2367,6 +2367,7 @@ def test_relative_future_dates( [ param("15th of Aug, 2014 Diane Bennett"), param("4 heures ago"), + param("the 31st of the month"), param("the 31st of this month"), param("the 1st of last month 2 days ago"), ] @@ -2607,6 +2608,7 @@ def test_freshness_date_with_timezone_utc_offset( param("in 1.5 days", date(2010, 6, 6), time(1, 15)), param("0,5 hours ago", date(2010, 6, 4), time(12, 45)), # Day of a relative month + param("the 1st of the month", date(2010, 6, 1), time(13, 15)), param("the 1st of last month", date(2010, 5, 1), time(13, 15)), param("the 1st of this month", date(2010, 6, 1), time(13, 15)), param("30th of next month at 5pm", date(2010, 7, 30), time(17, 0)), diff --git a/tests/test_search.py b/tests/test_search.py index e4296e903..6ffab11d6 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1140,6 +1140,18 @@ def test_detection(self, shortname: str, text: str) -> None: ], ), param(text="a Americ", languages=None, settings=None, expected=None), + param( + text="Photo of the month, 12 March 1999", + languages=["en"], + settings=None, + expected=[("12 March 1999", datetime.datetime(1999, 3, 12, 0, 0))], + ), + param( + text="Employee of the month", + languages=["en"], + settings=None, + expected=None, + ), # Date with comma and apostrophe param( text="9/3/2017 , ",