Fix timezone handling in MLB game time display

This commit is contained in:
ChuckBuilds
2025-04-24 20:10:53 -05:00
parent 441844ebed
commit b23b57704d

View File

@@ -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')