scrapinghub / scrapinghub/dateparser
1.2.0 - PREFER_DATES_FROM & Timezone bug
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 520
- Avg merge
- 22h 56m
- Merged PRs (30d)
- 6
Description
It's currently 08/10/2024 23:37 pm Europe/London time. Observe the following code,
time_zone = 'Europe/London'
tz_result = dateparser.parse('at 12am', settings={'PREFER_DATES_FROM' : 'future', 'TIMEZONE': time_zone})
normal_result = dateparser.parse('at 12am', settings={'PREFER_DATES_FROM': 'future'})
print(tz_result)
print(normal_result)
I'd be expecting both results to print, 2024-10-09 00:00:00. The actual prints are,
2024-10-08 00:00:00
2024-10-09 00:00:00
this may be intended behaviour but it doesn't seem like it from my perspective.
Edit: Possibly this is user error, as using 'TO_TIMEZONE' : time_zone instead of TIMEZONE : time_zone seems to return the correct 12am for the tz_result variable. Although I'm a still little confused on why "TIMEZONE" was returning me the previous day's 12am since I've specified PREFER_DATES_FROM_FUTURE. If anyone knows why I'd love to hear it, thanks
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 by reproducing the reported dateparser.parse calls with PREFER_DATES_FROM, TIMEZONE, and TO_TIMEZONE using the example timestamp and Europe/London. Read the dateparser.parse timezone and relative-date handling, then determine whether the differing midnight results are intended or need correction. Done means the behavior is clarified and, if incorrect, covered by a regression test.
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
- Needs clarification
- Newbie friendliness
- 35/100