From f1602eca70378ea840c712fedcf6555d4d30325a Mon Sep 17 00:00:00 2001 From: Nikhil Sasi <103910538+NeonEvergreen@users.noreply.github.com> Date: Fri, 28 Mar 2025 08:28:42 +0530 Subject: [PATCH] Fix date parsing error: prevent negative days by using timedelta (#264) subtracting extracted "days" from label with current day causes negative days datetime class rejects negative day association Use timedelta for proper date limitation Co-authored-by: NIKHIL S --- jobspy/naukri/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobspy/naukri/__init__.py b/jobspy/naukri/__init__.py index 624073c..0a97bf0 100644 --- a/jobspy/naukri/__init__.py +++ b/jobspy/naukri/__init__.py @@ -3,7 +3,7 @@ from __future__ import annotations import math import random import time -from datetime import datetime, date +from datetime import datetime, date, timedelta from typing import Optional import regex as re @@ -277,7 +277,7 @@ class Naukri(Scraper): match = re.search(r"(\d+)\s*day", label) if match: days = int(match.group(1)) - parsed_date = today.replace(day=today.day - days).date() + parsed_date = (today - timedelta(days = days)).date() log.debug(f"Date parsed: {days} days ago -> {parsed_date}") return parsed_date elif created_date: