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

Parse short versions of day, month and year #1103

Merged
merged 1 commit into from Nov 24, 2022
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
3 changes: 3 additions & 0 deletions dateparser/data/date_translation_data/en.py
Expand Up @@ -87,11 +87,13 @@
"year": [
"year",
"yr",
"y",
"years"
],
"month": [
"mo",
"month",
"mon",
"months"
],
"week": [
Expand All @@ -101,6 +103,7 @@
],
"day": [
"day",
"d",
"days"
],
"hour": [
Expand Down
Expand Up @@ -13,12 +13,15 @@ decade:
- decade
- decades
year:
- y
- years
month:
- mon
- months
week:
- weeks
day:
- d
- days
hour:
- h
Expand Down
3 changes: 3 additions & 0 deletions tests/test_freshness_date_parser.py
Expand Up @@ -72,6 +72,7 @@ def test_relative_past_dates_with_time_as_period(self, date_string, ago, period)
param('an hour ago', ago={'hours': 1}, period='day'),
param('about an hour ago', ago={'hours': 1}, period='day'),
param('a day ago', ago={'days': 1}, period='day'),
param('1d ago', ago={'days': 1}, period='day'),
param('a week ago', ago={'weeks': 1}, period='week'),
param('2 hours ago', ago={'hours': 2}, period='day'),
param('about 23 hours ago', ago={'hours': 23}, period='day'),
Expand All @@ -96,8 +97,10 @@ def test_relative_past_dates_with_time_as_period(self, date_string, ago, period)
param('nine hours ago', ago={'hours': 9}, period='day'),
param('three week ago', ago={'weeks': 3}, period='week'),
param('eight months ago', ago={'months': 8}, period='month'),
param('1mon ago', ago={'months': 1}, period='month'),
param('six days ago', ago={'days': 6}, period='day'),
param('five years ago', ago={'years': 5}, period='year'),
param('2y ago', ago={'years': 2}, period='year'),
# Fractional units
param('2.5 hours', ago={'hours': 2.5}, period='day'),
param('10.75 minutes', ago={'minutes': 10.75}, period='day'),
Expand Down