Skip to content

Conversation

adnan-awan
Copy link
Contributor

@adnan-awan adnan-awan commented Jan 28, 2024

Fixes #1170

@adnan-awan adnan-awan requested review from wRAR and Gallaecio January 28, 2024 14:13
@wRAR
Copy link
Member

wRAR commented Jan 29, 2024

Please check https://github.com/scrapinghub/dateparser/blob/master/CONTRIBUTING.rst#guidelines-for-editing-translation-data about editing language data (you edited a generated file).

@adnan-awan adnan-awan closed this Jan 30, 2024
@adnan-awan adnan-awan force-pushed the fix-short-weekday-names-1170 branch from 1e4c73c to 30e2c7f Compare January 30, 2024 05:33
- Update en.yaml file to support two letters days of the week
- #1170
@adnan-awan adnan-awan reopened this Jan 30, 2024
@Gallaecio
Copy link
Member

Any idea about the failing test?

- Develop method to remove_multiple_occurrences of the day(s) of the week
- #1170
@Gallaecio
Copy link
Member

Could you add tests for the fix itself? (7 dates with the short weekday form that are properly parsed) I think that’s all that’s left.

Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.50%. Comparing base (0667cb3) to head (1865917).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1214      +/-   ##
==========================================
+ Coverage   97.49%   97.50%   +0.01%     
==========================================
  Files         234      234              
  Lines        2793     2806      +13     
==========================================
+ Hits         2723     2736      +13     
  Misses         70       70              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +934 to +935
def then_date_was_not_parsed(self):
self.assertIsNone(self.result["date_obj"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unused now.

Comment on lines -836 to +898
now = datetime(year, month, day, **time)
datetime_mock = Mock(wraps=datetime)
datetime_mock.utcnow = Mock(return_value=now)
datetime_mock.now = Mock(return_value=now)
datetime_mock.today = Mock(return_value=now)
self.add_patch(patch("dateparser.date.datetime", new=datetime_mock))
now = real_datetime.datetime(year, month, day, **time)

# Patch the datetime *class* in each target module
class DateParserDateTime(real_datetime.datetime):
@classmethod
def now(cls, tz=None):
return now.replace(tzinfo=tz) if tz else now

@classmethod
def utcnow(cls):
return now

@classmethod
def today(cls):
return now

self.add_patch(patch("dateparser.date.datetime", DateParserDateTime))
self.add_patch(patch("dateparser.parser.datetime", DateParserDateTime))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what this change does?

@@ -145,6 +170,7 @@ def translate(self, date_string, keep_formatting=False, settings=None):
if "in" in date_string_tokens:
date_string_tokens = self._clear_future_words(date_string_tokens)

self.remove_multiple_occurrences(date_string_tokens)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? None of the new test scenarios seem to feature multiple occurrences of a week day. What scenarios does this address? (I wonder if it could be introducing other issues)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing very short weekday names
3 participants