Skip to content

Commit

Permalink
fuzzy date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
shakedzy authored Jul 3, 2024
1 parent 34e25d5 commit c693e79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion techbyai/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _validate_published_date(google_search_result: dict[str, Any]) -> bool | Non
published_date: str | None = google_search_result.get('pagemap', {}).get('metatags', [{}])[0].get('article:published_time', None)
if not published_date:
return None
dt = parser.parse(published_date).astimezone(pytz.utc)
dt = parser.parse(published_date, fuzzy=True).astimezone(pytz.utc)
date_cutoff = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(days=Settings().search.past_days)
date_cutoff = pytz.utc.localize(date_cutoff)
return dt >= date_cutoff
Expand Down

0 comments on commit c693e79

Please sign in to comment.