Skip to content

Prepositions with turn of year ignore turn of year #1295

Description

@htgoebel

If the seach_dates finds two dates "from … until", the turn of year is not recognized.

Expected

"Closed from December 23th until January 7th" to be parsed into
(today.year, 12, 23, 0, 0) and (today.year+1, 1, 8, 0, 0).

Wish

Even better would be if the year would depend on the distance to today:
Aforementioned string would parse into

  • last-year, this-year if today is "near" January 7th.
  • this-year, next-year if today is "near" December 23th

Test case

    def test_search_dates_with_prepositions_with_turn_of_year(self):
        """Test `search_dates` for parsing English date ranges with
        prepositions, turn of year and language detection.
        """
        result = search_dates(
            "Closed from 23th December until 8th January.",
            add_detected_language=True,
            languages=["en"],
        )
        expected = [
            ("23th December", datetime.datetime(today.year, 12, 23, 0, 0), "en"),
            ("8th January", datetime.datetime(today.year+1, 1, 8, 0, 0), "en"),
        ]
        assert result == expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions