Skip to content

Commit

Permalink
fix Python offset formatting to conform to stricter black box tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ikluft committed May 14, 2024
1 parent a9d03ee commit 19c6ef5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/python/timezone_solar/timezone_solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 19c6ef5

Please sign in to comment.