Make more generic calculation
@@ -232,20 +232,13 @@ class Py3status:
format_time = self.format_time[self.active_time_format]
icon = None
if self.py3.format_contains(format_time, 'icon'):
- # calculate the hour to use for icon
- h = t.hour
- m = t.minute / 60.
+ # calculate the decimal hour
+ h = t.hour + t.minute / 60.
if self.round_to_nearest_block:
- if m < 0.25:
- m = 0
- elif m >= 0.25 and m < 0.75:
- m = 0.5
- else:
- h += 1
- m = 0
+ h += (self.block_hours / len(self.blocks)) / 2
# make 12 hourly etc
h = h % self.block_hours
- idx = int((h + m) / self.block_hours * len(self.blocks))
+ idx = int(h / self.block_hours * len(self.blocks))
icon = self.blocks[idx]
timezone = zone.zone
