From c6df1fc0d8abaa15c0b492d8730d0829bff8f26c Mon Sep 17 00:00:00 2001 From: Itz-fork Date: Tue, 26 Dec 2023 19:11:03 +0530 Subject: [PATCH] fix: TimeFormatter returning unreadable time --- megadl/lib/pyros.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/megadl/lib/pyros.py b/megadl/lib/pyros.py index a952a182..3655b59a 100644 --- a/megadl/lib/pyros.py +++ b/megadl/lib/pyros.py @@ -42,8 +42,17 @@ def TimeFormatter(milliseconds: int) -> str: minutes, seconds = divmod(seconds, 60) hours, minutes = divmod(minutes, 60) days, hours = divmod(hours, 24) - tmp = f"{days}d, {hours}h, {minutes}m, {seconds}s, {milliseconds}ms," - return tmp[:-2] + + if days > 0: + return f"{days}d" + elif hours > 0: + return f"{hours}h" + elif minutes > 0: + return f"{minutes}m" + elif seconds > 0: + return f"{seconds}s" + else: + return f"{milliseconds}ms" def humanbytes(size):