From 1cd35f261e45cae123612c8628720c3cef815bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ku=CC=88ch?= Date: Mon, 2 Apr 2018 14:31:54 +0200 Subject: [PATCH 1/2] Added option for military time --- mlbstreamer/__main__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mlbstreamer/__main__.py b/mlbstreamer/__main__.py index 4d733e6..78703d6 100644 --- a/mlbstreamer/__main__.py +++ b/mlbstreamer/__main__.py @@ -180,6 +180,16 @@ def set_game_date(self, game_date): self.game_date = game_date self.reset() + def format_localized_game_start_time(self, start_time): + 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 +233,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 ) From adc6c42e06c75b3bcd99ce7c5d08d72951f1ed78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ku=CC=88ch?= Date: Mon, 2 Apr 2018 14:38:23 +0200 Subject: [PATCH 2/2] Added docstring --- mlbstreamer/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mlbstreamer/__main__.py b/mlbstreamer/__main__.py index 78703d6..2573939 100644 --- a/mlbstreamer/__main__.py +++ b/mlbstreamer/__main__.py @@ -181,6 +181,7 @@ def set_game_date(self, 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: