Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for after and before relative dates #1008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions dateparser/data/date_translation_data/en.py
Expand Up @@ -189,6 +189,9 @@
],
"in 1 decade": [
"next decade"
],
"in 2 day": [
"day after tomorrow"
]
},
"relative-type-regex": {
Expand Down Expand Up @@ -773,11 +776,13 @@
"decades"
],
"ago": [
"ago"
"ago",
"before"
],
"in": [
"in",
"from now"
"from now",
"after"
],
"simplifications": [
{
Expand Down
Expand Up @@ -35,9 +35,11 @@ second:

ago:
- ago
- before
in:
- in
- from now
- after

relative-type:
2 day ago:
Expand All @@ -47,6 +49,8 @@ relative-type:
- this decade
in 1 decade:
- next decade
in 2 day:
- day after tomorrow
0 day ago:
- till date

Expand Down
4 changes: 4 additions & 0 deletions tests/test_freshness_date_parser.py
Expand Up @@ -66,6 +66,7 @@ def test_relative_past_dates_with_time_as_period(self, date_string, ago, period)
param("100 decades", ago={'years': 1000}, period='year'),
param('yesterday', ago={'days': 1}, period='day'),
param('the day before yesterday', ago={'days': 2}, period='day'),
param('4 days before', ago={'days': 4}, period='day'),
param('today', ago={'days': 0}, period='day'),
param('till date', ago={'days': 0}, period='day'),
param('an hour ago', ago={'hours': 1}, period='day'),
Expand Down Expand Up @@ -591,6 +592,7 @@ def test_relative_past_dates(self, date_string, ago, period):
param("100 decades", ago={'years': 1000}, period='year'),
param('yesterday', ago={'days': 1}, period='day'),
param('the day before yesterday', ago={'days': 2}, period='day'),
param('10 days before', ago={'days': 10}, period='day'),
param('today', ago={'days': 0}, period='day'),
param('till date', ago={'days': 0}, period='day'),
param('an hour ago', ago={'hours': 1}, period='day'),
Expand Down Expand Up @@ -1084,6 +1086,8 @@ def test_normalized_relative_dates(self, date_string, ago, period):
param('next decade', in_future={'years': 10}, period='year'),
param('in a decade', in_future={'years': 10}, period='year'),
param('tomorrow', in_future={'days': 1}, period='day'),
param('day after tomorrow', in_future={'days': 2}, period='day'),
param('after 4 days', in_future={'days': 4}, period='day'),
param('today', in_future={'days': 0}, period='day'),
param('till date', in_future={'days': 0}, period='day'),
param('in an hour', in_future={'hours': 1}, period='day'),
Expand Down