scrapinghub / scrapinghub/dateparser
"hh:mm" incorrectly jumps 24 hours ahead when date in localtime is ahead of UTC date (eg New Zealand)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
Severe issue where parseDate("hh:mm") in some circumstances jumps one day ahead of where it should.
I'm in New Zealand (UTC+12).
At 2021-06-04 19:30 +00:00:00 (UTC), the local datetime in New Zealand is 2021-06-05 07:30:00.
At this time, when I call:
- parseDate("19:40")
I get: - datetime.datetime(2021, 6, 5, 19, 40)
However, last night when I used it (when the date in NZ was same as UTC - 2021-06-04), this "24 hours in the future" behaviour does not occur.
The bug only seems to happen when the localtime date in New Zealand is a day ahead of the UTC date. For New Zealand, this is between 12:00:00-23:59:59 UTC, or between 00:00:00-11:59:59 NZST.
Fix would be to test if localtime date is ahead of UTC date, and if so, adjust accordingly.
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
Start at the parseDate("hh:mm") entry point and reproduce the report using a UTC time when New Zealand's local date is already the next day. Trace how the date is chosen for time-only input, then verify that the result stays on the intended date across the UTC/NZ boundary and add coverage for the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100