scrapinghub / scrapinghub/dateparser

1.2.0 - PREFER_DATES_FROM & Timezone bug

Open
#1,239 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.