scrapinghub / scrapinghub/dateparser

Broken logic while parse 'Today' type of string with the time offset

Open
#460 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
Python
Stars
2.9k
Forks
520
Avg merge
22h 56m
Merged PRs (30d)
6

Description

Hi. I found some bug while parsing the date. I will try to explain with examples.
In every parse, we use time offset (important, TIMEZONE must be more than your own).
For example, right now 23:00 and our timezone is +0300.
we parse the string "26.10.2018 05:28 PM" with timezone +0400 to our timezone. This time dateparser work right:

datetime.datetime(2018, 10, 26, 16, 28)

But if we will parse the string "Today 05:28 PM" with timezone +0400 to our timezone, dateparser will make mistake:

datetime.datetime(2018, 10, 27, 16, 28).

I guess, that this mistake appears from using datetime.datetime.now() when converting "Today" and converting timezone from our server time. It is not correct.
Please, can you fix this mistake?

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 two examples in the issue using the stated timezone offset, comparing the explicit date with the "Today" input. Trace the relative-date parsing and timezone conversion entry points; done means "Today 05:28 PM" resolves to the same intended calendar day as the explicit-date case.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.