From b23b57704deffb2c88e97ebdfbeb566a57982c5a Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 24 Apr 2025 20:10:53 -0500 Subject: [PATCH] Fix timezone handling in MLB game time display --- src/mlb_manager.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mlb_manager.py b/src/mlb_manager.py index 0ccc10be..b4c4960d 100644 --- a/src/mlb_manager.py +++ b/src/mlb_manager.py @@ -161,7 +161,14 @@ class BaseMLBManager: def _format_game_time(self, game_time: str) -> str: """Format game time for display.""" try: + # Get timezone from config + timezone_str = self.config.get('timezone', 'UTC') + tz = timezone(timedelta(hours=0)) # Default to UTC if timezone not found + + # Convert game time to local timezone dt = datetime.fromisoformat(game_time.replace('Z', '+00:00')) + dt = dt.astimezone(tz) + return dt.strftime("%I:%M %p") except Exception as e: logger.error(f"Error formatting game time: {e}") @@ -205,6 +212,10 @@ class BaseMLBManager: game_id = event['id'] status = event['status']['type']['name'].lower() + # Log the full status object for debugging + self.logger.info(f"Game {game_id} status object: {event['status']}") + self.logger.info(f"Game {game_id} status type: {status}") + # Get team information competitors = event['competitions'][0]['competitors'] home_team = next(c for c in competitors if c['homeAway'] == 'home')