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.
This commit is contained in:
Erik Johnson 2021-04-29 18:35:34 -05:00 committed by GitHub
parent b0826cf6ca
commit cf3123b415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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