From 40ab8b761fd0bfff724637173bc0e5c301eacd59 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Fri, 25 Apr 2025 11:12:01 -0500 Subject: [PATCH] fix: Properly convert game times to local timezone in MLB display --- src/mlb_manager.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/mlb_manager.py b/src/mlb_manager.py index f334a529..b9e104e9 100644 --- a/src/mlb_manager.py +++ b/src/mlb_manager.py @@ -145,8 +145,19 @@ class BaseMLBManager: # Format game date and time game_time = datetime.fromisoformat(game_data['start_time'].replace('Z', '+00:00')) - game_date = game_time.strftime("%b %d") # e.g., "Apr 24" - game_time_str = game_time.strftime("%I:%M %p") # e.g., "07:30 PM" + # Get timezone from config + timezone_str = self.config.get('timezone', 'UTC') + try: + tz = pytz.timezone(timezone_str) + except pytz.exceptions.UnknownTimeZoneError: + logger.warning(f"Unknown timezone: {timezone_str}, falling back to UTC") + tz = pytz.UTC + # Convert to local timezone + if game_time.tzinfo is None: + game_time = game_time.replace(tzinfo=pytz.UTC) + local_time = game_time.astimezone(tz) + game_date = local_time.strftime("%b %d") # e.g., "Apr 24" + game_time_str = local_time.strftime("%I:%M %p") # e.g., "07:30 PM" # Draw date in center using PressStart2P date_bbox = draw.textbbox((0, 0), game_date, font=self.display_manager.font)