Skip to content

Commit

Permalink
Parse Monday (#1121)
Browse files Browse the repository at this point in the history
* Parse Monday

Close #1116

* Add test_known_issues
  • Loading branch information
serhii73 authored Jan 11, 2023
1 parent 78dc298 commit 1db73ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion dateparser/data/date_translation_data/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"month": [
"mo",
"month",
"mon",
"months"
],
"week": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ year:
- y
- years
month:
- mon
- months
week:
- weeks
Expand Down
2 changes: 2 additions & 0 deletions tests/test_date_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ def test_dates_not_parsed(self, date_string, message):
param('March', datetime(2014, 3, 15)),
param('Friday', datetime(2015, 2, 13)),
param('Monday', datetime(2015, 2, 9)),
param('Mon', datetime(2015, 2, 9)),
param('Sunday', datetime(2015, 2, 8)), # current day
param('10:00PM', datetime(2015, 2, 14, 22, 0)),
param('16:10', datetime(2015, 2, 14, 16, 10)),
Expand Down Expand Up @@ -759,6 +760,7 @@ def test_period_is_time_if_return_time_as_period_setting_applied_and_time_compon
@parameterized.expand([
param('16:00', expected=datetime(2018, 12, 13, 16, 0), period='time'),
param('Monday 7:15 AM', expected=datetime(2018, 12, 10, 7, 15), period='time'),
param('Mon 19:43', expected=datetime(2018, 12, 10, 19, 43), period='time'),
])
def test_period_is_time_if_return_time_as_period_and_relative_base_settings_applied_and_time_component_present(
self, date_string, expected=None, period=None
Expand Down
11 changes: 10 additions & 1 deletion tests/test_freshness_date_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ 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'),
Expand Down Expand Up @@ -1518,6 +1517,16 @@ def test_dates_not_supported_by_date_time(self, date_string):
self.then_error_was_not_raised()
self.assertEqual(None, self.result['date_obj'])

@parameterized.expand([
param('1mon ago'), #1116
])
def test_known_issues(self, date_string):
self.given_parser()
self.given_date_string(date_string)
self.when_date_is_parsed()
self.then_error_was_not_raised()
self.assertEqual(None, self.result['date_obj'])

@parameterized.expand([
param('несколько секунд назад', boundary={'seconds': 45}, period='day'),
param('há alguns segundos', boundary={'seconds': 45}, period='day'),
Expand Down

0 comments on commit 1db73ee

Please sign in to comment.