From beb471d081bf5dbb60048b7d643a77e38d55aafd Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Sat, 18 Oct 2025 14:47:47 -0400 Subject: [PATCH] fix: fixing db time again --- VERSION | 2 +- api/routes.py | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index 7bf4b6a..e30309f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.6 +2.4.7 diff --git a/api/routes.py b/api/routes.py index e2ba023..e63eadf 100644 --- a/api/routes.py +++ b/api/routes.py @@ -546,26 +546,23 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N import os start_time = datetime.now() - # Try to get local timezone - handle Docker container case + # Handle timezone display - check if TZ is set in container try: - # Check if TZ environment variable is set tz_name = os.environ.get('TZ') if tz_name: - import zoneinfo - local_tz = zoneinfo.ZoneInfo(tz_name) - local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz) + # TZ is set, so datetime.now() already returns local time + local_start = start_time tz_display = f" ({tz_name})" else: - # Fallback: assume EDT/EST based on PostgreSQL logs showing EDT - # This is a reasonable assumption for your deployment + # No TZ set, assume container is UTC and convert to Eastern import zoneinfo local_tz = zoneinfo.ZoneInfo("America/New_York") local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz) tz_display = " (EDT/EST)" except: - # Ultimate fallback - just show UTC with note + # Ultimate fallback - just show time as-is with note local_start = start_time - tz_display = " (UTC - container time)" + tz_display = " (container time)" print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {local_start.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}") @@ -658,16 +655,18 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N try: tz_name = os.environ.get('TZ') if tz_name: - local_tz = zoneinfo.ZoneInfo(tz_name) - local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz) + # TZ is set, so datetime.now() already returns local time + local_end = end_time tz_display = f" ({tz_name})" else: + # No TZ set, assume container is UTC and convert to Eastern + import zoneinfo local_tz = zoneinfo.ZoneInfo("America/New_York") local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz) tz_display = " (EDT/EST)" except: local_end = end_time - tz_display = " (UTC - container time)" + tz_display = " (container time)" print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {local_end.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}") print(f"⏱️ MANUAL SCAN DURATION: {duration_str} (total time: {duration.total_seconds():.1f} seconds)")