feat(bot): ✨ Add support for showing years in time-to-text.
This commit is contained in:
@@ -206,11 +206,14 @@ def time_to_text(time_diff: timedelta) -> str:
|
|||||||
str: The string representation.
|
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)
|
hours, remainder = divmod(time_diff.seconds, 3600)
|
||||||
minutes, seconds = divmod(remainder, 60)
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
|
||||||
parts = []
|
parts = []
|
||||||
|
if years > 0:
|
||||||
|
parts.append(f"{years} day{"s" if years != 1 else ""}")
|
||||||
if days > 0:
|
if days > 0:
|
||||||
parts.append(f"{days} day{"s" if days != 1 else ""}")
|
parts.append(f"{days} day{"s" if days != 1 else ""}")
|
||||||
if hours > 0:
|
if hours > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user