Skip to content
This repository was archived by the owner on Apr 26, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions mlbstreamer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ def set_game_date(self, game_date):
self.game_date = game_date
self.reset()

def format_localized_game_start_time(self, start_time):
""" Formats start_time to preferred time format set by military_time flag in config """
if config.settings.military_time:
return start_time.time().strftime("%H:%M")
else:
return "%d:%02d%s" %(
start_time.hour - 12 if start_time.hour > 12 else start_time.hour,
start_time.minute,
"p" if start_time.hour >= 12 else "a"
)

def query(self, *args, **kwargs):

j = state.session.schedule(
Expand Down Expand Up @@ -223,11 +234,7 @@ def query(self, *args, **kwargs):
game_type = game_type,
away = away_team,
home = home_team,
start = "%d:%02d%s" %(
start_time.hour - 12 if start_time.hour > 12 else start_time.hour,
start_time.minute,
"p" if start_time.hour >= 12 else "a"
),
start = self.format_localized_game_start_time(start_time),
line = self.line_score
)

Expand Down