screen_panel: format_time round minutes since seconds are only shown with less than a minute

This commit is contained in:
alfrix 2023-07-16 16:42:38 -03:00 committed by Alfredo Monclus
parent d0ab325744
commit 870256df09

View File

@ -121,13 +121,13 @@ class ScreenPanel:
@staticmethod @staticmethod
def format_time(seconds): def format_time(seconds):
if seconds is None or seconds <= 0: if seconds is None or seconds < 1:
return "-" return "-"
days = seconds // 86400 days = seconds // 86400
seconds %= 86400 seconds %= 86400
hours = seconds // 3600 hours = seconds // 3600
seconds %= 3600 seconds %= 3600
minutes = seconds // 60 minutes = round(seconds / 60)
seconds %= 60 seconds %= 60
return f"{f'{days:2.0f}d ' if days > 0 else ''}" \ return f"{f'{days:2.0f}d ' if days > 0 else ''}" \
f"{f'{hours:2.0f}h ' if hours > 0 else ''}" \ f"{f'{hours:2.0f}h ' if hours > 0 else ''}" \