scrapinghub / scrapinghub/dateparser

When mixing h/m/s, results are absolute even though using "in"

Open
#677 0 comments 2 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

>>> str(dateparser.parse("in 3h10m", languages=["en"], settings={"PREFER_DATES_FROM": "future"}))
'2020-05-15 03:10:00'
>>> str(dateparser.parse("in 3h 10m", languages=["en"], settings={"PREFER_DATES_FROM": "future"}))
'2020-05-15 01:27:24.920769'

I feel like those two should be identical. Same result without settings or languages specified.

This might be due to https://github.com/scrapinghub/dateparser/blob/master/dateparser_data/supplementary_language_data/date_translation_data/en.yaml#L48
Removing it fixes the issue

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

Reproduce the two examples first, then inspect dateparser_data/supplementary_language_data/date_translation_data/en.yaml around line 48. Verify how the translation entry affects spaced and unspaced h/m/s expressions. Done means both inputs produce equivalent relative results and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.