Fix day+month+year dates collapsing to the whole month - #2791
Merged
Conversation
extract_period() runs before dateparser and matches "<month> <year>", so "meeting on 13 July 2024" was widened to 2024-07-01..2024-07-31 and the day was lost. Skip the month-table match when a day number precedes the month, letting dateparser resolve the exact date instead. Language-agnostic: affects every language in the period table (English shown in the test). Split out of vectorize-io#2767 per review so the correctness fix can land independently of the Russian-coverage change.
nicoloboschi
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
extract_period()(the deterministic period table) runs before dateparser and matches<month> <year>. When a day number precedes the month, the table still fires and widens the query to the whole month, dropping the day:This is language-agnostic — it affects every language in the period table, and it bites English today.
Fix
Guard the month-table match with a day-number check: if a day precedes the month, skip the table and let dateparser resolve the exact date (dateparser handles
13 July 2024correctly).Tests
Added
test_query_analyzer_day_month_year_stays_exact(English case). Verified locally on both dateparser versions:1.2.2— the version pinned in the lock / run by CI1.4.1— the version actually shipped inside theghcr.io/vectorize-io/hindsight:0.8.4imageFull
test_query_analyzer.pyis green (383 passed) on both.Context
Split out of #2767 per @benfrank241's review, so this correctness fix can land independently of the Russian-coverage change. #2767 now stacks on this PR.