feat(bot): ✨ Add support for showing years in time-to-text.

This commit is contained in:
Nyeki.py
2024-10-18 22:49:01 -03:00
parent ec82479d0f
commit 15db5d429d
+4 -1
View File
@@ -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: