fix: allow 'N {interval} from now' (#502)
This is a copy of PR https://github.com/scrapinghub/dateparser/pull/642 which fixes https://github.com/scrapinghub/dateparser/issues/502. I'm not sure why it was closed, or if this is the right way to re-submit it. Afaict it's a general fix that works in all cases.
Before:
$ python -c "from dateparser import parse; from datetime import datetime ; print(parse('in 2 days', settings={'RELATIVE_BASE': datetime.now()}))"
2025-05-19 00:34:29.964320
$ python -c "from dateparser import parse; from datetime import datetime ; print(parse('2 days fron now', settings={'RELATIVE_BASE': datetime.now()}))"
None
After:
$ python -c "from dateparser import parse; from datetime import datetime ; print(parse('in 2 days', settings={'RELATIVE_BASE': datetime.now()}))"
2025-05-19 00:34:29.964320
$ python -c "from dateparser import parse; from datetime import datetime ; print(parse('2 days fron now', settings={'RELATIVE_BASE': datetime.now()}))"
2025-05-19 00:34:29.964320
Can we get this merged? Would like to have support for "* from now" format
Closing and reopening to see if CI triggers.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 96.58%. Comparing base (bdc57d3) to head (a795ec0).
Additional details and impacted files
@@ Coverage Diff @@
## master #1271 +/- ##
=======================================
Coverage 96.58% 96.58%
=======================================
Files 235 235
Lines 2866 2866
=======================================
Hits 2768 2768
Misses 98 98
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
It seems tests do not pass.
a = (<tests.test_freshness_date_parser.TestFreshnessDateDataParser testMethod=test_relative_past_dates_038_7_years_from_now>,)
kw = {}
@wraps(func)
def standalone_func(*a, **kw):
> return func(*(a + p.args), **p.kwargs, **kw)
E TypeError: test_relative_past_dates() got an unexpected keyword argument 'in_future'
.tox/min-all/lib/python3.9/site-packages/parameterized/parameterized.py:620: TypeError
The test cases were decorating the wrong function, they should pass now.