Skip to content

Commit

Permalink
clock module: minor patch to get the local timezone. (#2189)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Sixsmith <josh.sixsmith@gmail.com>
  • Loading branch information
sixy6e and Josh Sixsmith committed May 30, 2023
1 parent d27bb85 commit 8eadd60
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions py3status/modules/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ def _get_timezone(self, tz):
"""
# special Local timezone
if tz == "Local":
try:
return zoneinfo.ZoneInfo("localtime")
except zoneinfo.ZoneInfoNotFoundError:
return "?"
return None
# get the timezone
try:
zone = zoneinfo.ZoneInfo(tz)
Expand Down Expand Up @@ -251,8 +248,12 @@ def clock(self):
idx = int(h / self.block_hours * len(self.blocks))
icon = self.blocks[idx]

timezone = zone.key
tzname = timezone.split("/")[-1].replace("_", " ")
# special case for handling Local timezone
if zone is None:
timezone, tzname = None, None
else:
timezone = zone.key
tzname = timezone.split("/")[-1].replace("_", " ")

if self.multiple_tz:
name_unclear = tzname
Expand Down

0 comments on commit 8eadd60

Please sign in to comment.