Repository navigation
fix(utils): detect date precision without counting dashes - #4007
Open
LemonCondor wants to merge 1 commit into
Open
LemonCondor wants to merge 1 commit into
LemonCondor wants to merge 1 commit into
Conversation
…tateam#4006) daterange_start and daterange_end treated any value without two dashes as a year/month or a year only, so "2020/05/17", "20200517" or "May 2020" became the whole of 2020. Find which parts were given by parsing the value against two different default dates instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Fix #4006.
daterange_start/daterange_endguessed the precision of a date (full date, year/month, year) by counting-characters, so values such as2020/05/17,20200517orMay 2020— whichdateutilparses correctly — were turned into the whole year 2020. These functions parse the free-texttemporal_start/temporal_endextras of the CKAN harvester.The new
_parse_date_precisionhelper parses the value against two different default dates (January 1st and March 3rd of the current year, both in 31-day months): a month or day that is identical in both results was given explicitly. Dashed values keep exactly the same result, and the current year is still used when a value has no year, as before.Tests: two new cases in
DateRangeTest(full dates and year/month without dashes) fail before the change and pass after;pytest udata/tests/test_utils.py→ 54 passed.ruff format --checkpasses;ruff checkreports the same pre-existing warnings as onmainfor these two files.🤖 Generated with Claude Code