From 19c6ef505c3a9855b11cb32a9d7402243851d95e Mon Sep 17 00:00:00 2001 From: Ian Kluft Date: Mon, 13 May 2024 23:52:03 -0700 Subject: [PATCH] fix Python offset formatting to conform to stricter black box tests --- src/python/timezone_solar/timezone_solar.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/python/timezone_solar/timezone_solar.py b/src/python/timezone_solar/timezone_solar.py index cf16ea4..246b33d 100644 --- a/src/python/timezone_solar/timezone_solar.py +++ b/src/python/timezone_solar/timezone_solar.py @@ -201,9 +201,10 @@ def _str_long_name(self) -> str: def _str_offset(self) -> str: """read accessor for offset field""" offset_min = getattr(self, "offset_min") - hours = str(int(offset_min / 60)) - minutes = str(offset_min % 60).zfill(2) - return f"{hours}:{minutes}" + sign = "+" if offset_min >= 0 else "-" + hours = str(int(abs(offset_min) / 60)).zfill(2) + minutes = str(abs(offset_min) % 60).zfill(2) + return f"{sign}{hours}:{minutes}" def _str_offset_sec(self) -> str: """read accessor for offset_sec field"""