diff --git a/mlbstreamer/__main__.py b/mlbstreamer/__main__.py index 4d733e6..2573939 100644 --- a/mlbstreamer/__main__.py +++ b/mlbstreamer/__main__.py @@ -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( @@ -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 )