scrapinghub / scrapinghub/dateparser
REQUIRE_PARTS should support 'hour' and 'minute'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
The setting 'REQUIRE_PARTS' is a nice and clean way to ensure the date contains parts. However, it only supports 'year', 'month', 'day'. Thus, it is currently not possible to use dateparser to just get hour and minute (without date) reliably.
The problem is that dateparser always returns a datetime object, where 'hour' and 'minute' default to 0. Thus, parsing a date like
"2020-10-10" and then checking the hour and minute of the result will give the time(hour=0, minute=0).
Of course one could ignore all results that have 0 in 'hour' and 'minute', but then parsing '0:00' (a valid time) would not work anymore. The two cases are currently indistinguishable.
I guess the best way to fix would be to support 'hour' and 'minute' in 'REQUIRE_PARTS'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names REQUIRE_PARTS and dateparser's datetime parsing behavior, but no source file or test. Start by locating REQUIRE_PARTS and the existing checks for year, month, and day. Done means hour and minute can be required independently, while valid zero-valued times remain distinguishable from missing time parts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100