From 15db5d429d8817f40f56d724f01e8454e765a79b Mon Sep 17 00:00:00 2001 From: "Nyeki.py" <84998222+Nekidev@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:49:01 -0300 Subject: [PATCH] feat(bot): :sparkles: Add support for showing years in time-to-text. --- payphone/core/formatting.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/payphone/core/formatting.py b/payphone/core/formatting.py index f4e5d82..518ace1 100644 --- a/payphone/core/formatting.py +++ b/payphone/core/formatting.py @@ -206,11 +206,14 @@ def time_to_text(time_diff: timedelta) -> str: str: The string representation. """ - days = time_diff.days + years = time_diff.days // 365 + days = time_diff.days % 365 hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds = divmod(remainder, 60) parts = [] + if years > 0: + parts.append(f"{years} day{"s" if years != 1 else ""}") if days > 0: parts.append(f"{days} day{"s" if days != 1 else ""}") if hours > 0: