~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: Fix all datetime usage to use UTC timezone
LearningCircuit97237673e4bd
diff --git a/.pre-commit-hooks/custom-checks.py b/.pre-commit-hooks/custom-checks.pyindex 7f813a465d..d8c78d7150 100755--- a/.pre-commit-hooks/custom-checks.py+++ b/.pre-commit-hooks/custom-checks.py@@ -309,6 +309,61 @@ def check_raw_sql(content: str, filename: str) -> List[Tuple[int, str]]:return errors+def check_datetime_usage(content: str, filename: str) -> List[Tuple[int, str]]:+ """Check for non-UTC datetime usage."""+ errors = []+ lines = content.split("\n")++ # Patterns to detect problematic datetime usage+ datetime_patterns = [+ # datetime.now() without timezone+ (+ r"datetime\.now\s*\(\s*\)",+ "Use datetime.now(UTC) or utc_now() instead of datetime.now()",+ ),+ # datetime.utcnow() - deprecated+ (+ r"datetime\.utcnow\s*\(\s*\)",+ "datetime.utcnow() is deprecated. Use datetime.now(UTC) or utc_now() instead",+ ),+ ]++ # Files where we allow datetime.now() for specific reasons+ allowed_files = [+ "test_", # Test files+ "mock_", # Mock files+ "/tests/", # Test directories+ ]++ # Check if this file is allowed to use datetime.now()+ is_allowed = any(pattern in filename.lower() for pattern in allowed_files)++ if not is_allowed:+ for line_num, line in enumerate(lines, 1):+ line_stripped = line.strip()++ # Skip comments and docstrings+ if (+ line_stripped.startswith("#")+ or line_stripped.startswith('"""')+ or line_stripped.startswith("'''")+ or not line_stripped+ ):+ continue++ # Check for problematic patterns+ for pattern, message in datetime_patterns:+ if re.search(pattern, line):+ # Check if it's already using UTC+ if (+ "datetime.now(UTC)" not in line+ and "timezone.utc" not in line+ ):+ errors.append((line_num, message))++ return errors++def check_file(filename: str) -> bool:"""Check a single Python file for violations."""if not filename.endswith(".py"):@@ -347,6 +402,10 @@ def check_file(filename: str) -> bool:sql_errors = check_raw_sql(content, filename)checker.errors.extend(sql_errors)+ # Check for datetime usage+ datetime_errors = check_datetime_usage(content, filename)+ checker.errors.extend(datetime_errors)+if checker.errors:print(f"\n{filename}:")for line_num, error in checker.errors:diff --git a/src/local_deep_research/news/subscription_manager/scheduler.py b/src/local_deep_research/news/subscription_manager/scheduler.pyindex ca957107f7..94954ff965 100644--- a/src/local_deep_research/news/subscription_manager/scheduler.py+++ b/src/local_deep_research/news/subscription_manager/scheduler.py@@ -5,7 +5,7 @@ Tracks user activity and temporarily stores credentials for automatic updates.import randomimport threading-from datetime import datetime, timedelta+from datetime import datetime, timedelta, UTCfrom typing import Any, Dict, Listfrom loguru import logger@@ -13,6 +13,7 @@ from loguru import loggerfrom apscheduler.schedulers.background import BackgroundSchedulerfrom apscheduler.jobstores.base import JobLookupError+SCHEDULER_AVAILABLE = True # Always available since it's a required dependency@@ -146,7 +147,7 @@ class NewsScheduler:self.scheduler.add_job(self._run_cleanup_with_tracking,"date",- run_date=datetime.now() + timedelta(seconds=30),+ run_date=datetime.now(UTC) + timedelta(seconds=30),id="initial_cleanup",)@@ -182,7 +183,7 @@ class NewsScheduler:returnwith self.lock:- now = datetime.now()+ now = datetime.now(UTC)if username not in self.user_sessions:# New user - create session info@@ -286,11 +287,11 @@ class NewsScheduler:trigger_args = {"minutes": refresh_minutes,"jitter": jitter,- "start_date": datetime.now(), # Start immediately+ "start_date": datetime.now(UTC), # Start immediately}else:# For less frequent, calculate next run time- now = datetime.now()+ now = datetime.now(UTC)if sub.next_refresh:# Convert to timezone-aware for comparisonnext_refresh_aware = sub.next_refresh.replace(@@ -424,12 +425,12 @@ class NewsScheduler:query = sub.query_or_topicif "YYYY-MM-DD" in query:query = query.replace(- "YYYY-MM-DD", datetime.now().date().isoformat()+ "YYYY-MM-DD", datetime.now(UTC).date().isoformat())# Update last/next refresh times- sub.last_refresh = datetime.utcnow()- sub.next_refresh = datetime.utcnow() + timedelta(+ sub.last_refresh = datetime.now(UTC)+ sub.next_refresh = datetime.now(UTC) + timedelta(minutes=sub.refresh_interval_minutes)db.commit()@@ -459,7 +460,7 @@ class NewsScheduler:job = self.scheduler.get_job(job_id)if job and job.trigger.__class__.__name__ == "DateTrigger":# For date triggers, reschedule- next_run = datetime.now() + timedelta(+ next_run = datetime.now(UTC) + timedelta(minutes=sub.refresh_interval_minutes,seconds=random.randint(0, int(self.config.get("max_jitter_seconds", 300))@@ -546,7 +547,7 @@ class NewsScheduler:"triggered_by": "scheduler","subscription_name": subscription["name"],"title": subscription["name"] if subscription["name"] else None,- "scheduled_at": datetime.utcnow().isoformat(),+ "scheduled_at": datetime.now(UTC).isoformat(),"original_query": subscription["original_query"],"user_id": username,}@@ -750,9 +751,9 @@ class NewsScheduler:title = generated_headlineelse:if subscription_name:- title = f"{subscription_name} - {datetime.now().isoformat(timespec='minutes')}"+ title = f"{subscription_name} - {datetime.now(UTC).isoformat(timespec='minutes')}"else:- title = f"{query_text[:60]}... - {datetime.now().isoformat(timespec='minutes')}"+ title = f"{query_text[:60]}... - {datetime.now(UTC).isoformat(timespec='minutes')}"# Create research history entryhistory_entry = ResearchHistory(@@ -760,8 +761,8 @@ class NewsScheduler:query=result.get("query", ""),mode="news_subscription",status="completed",- created_at=datetime.utcnow().isoformat(),- completed_at=datetime.utcnow().isoformat(),+ created_at=datetime.now(UTC).isoformat(),+ completed_at=datetime.now(UTC).isoformat(),title=title,research_meta={"subscription_id": subscription_id,@@ -811,7 +812,7 @@ class NewsScheduler:def _cleanup_inactive_users(self) -> int:"""Remove users inactive for longer than retention period."""retention_hours = self.config.get("retention_hours", 48)- cutoff = datetime.now() - timedelta(hours=retention_hours)+ cutoff = datetime.now(UTC) - timedelta(hours=retention_hours)cleaned_count = 0@@ -863,7 +864,7 @@ class NewsScheduler:self.scheduler.add_job(self._run_cleanup_with_tracking,"date",- run_date=datetime.now() + timedelta(seconds=5),+ run_date=datetime.now(UTC) + timedelta(seconds=5),id="immediate_cleanup_config_change",)@@ -913,7 +914,7 @@ class NewsScheduler:"last_activity": session["last_activity"].isoformat(),"scheduled_jobs": len(session["scheduled_jobs"]),"time_since_activity": str(- datetime.now() - session["last_activity"]+ datetime.now(UTC) - session["last_activity"]),})