From cf3123b415549d31cca83e60e2d81efefb95f2d0 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 29 Apr 2021 18:35:34 -0500 Subject: [PATCH] scores.nba: Fix timezone conversion (#815) When updating recently to support nba.com's new web API, I missed the fact that the game times were treating Eastern Time (US) as UTC and localizing based on that. This corrects that oversight. --- i3pystatus/scores/nba.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/i3pystatus/scores/nba.py b/i3pystatus/scores/nba.py index b2f5765..672d9c9 100644 --- a/i3pystatus/scores/nba.py +++ b/i3pystatus/scores/nba.py @@ -4,7 +4,7 @@ from i3pystatus.scores import ScoresBackend import copy import pytz import time -from datetime import datetime +from datetime import datetime, timezone LIVE_URL = 'https://www.nba.com/game/{id}' API_URL = 'https://cdn.nba.com/static/json/liveData/scoreboard/todaysScoreboard_00.json' @@ -269,8 +269,10 @@ class NBA(ScoresBackend): # From API data, date is YYYYMMDD, time is HHMM try: - game_et = game.get('gameEt', '') - game_time = datetime.strptime(game_et, '%Y-%m-%dT%H:%M:%S%z') + game_time = datetime.strptime( + game.get('gameTimeUTC', ''), + '%Y-%m-%dT%H:%M:%SZ' + ).replace(tzinfo=timezone.utc) except ValueError as exc: # Log when the date retrieved from the API return doesn't match the # expected format (to help troubleshoot API changes), and set an