Add support for plural/singular time periods
This commit is contained in:
parent
e38e357f63
commit
128d7ac282
|
@ -49,10 +49,10 @@ def human_readable_delta(future_date: date) -> str | None:
|
|||
# Formatting the output
|
||||
parts = []
|
||||
if months > 0:
|
||||
parts.append(f"{months} months")
|
||||
parts.append(f"{months} month{'s' if months > 1 else ''}")
|
||||
if weeks > 0:
|
||||
parts.append(f"{weeks} weeks")
|
||||
parts.append(f"{weeks} week{'s' if weeks > 1 else ''}")
|
||||
if days > 0:
|
||||
parts.append(f"{days} days")
|
||||
parts.append(f"{days} day{'s' if days > 1 else ''}")
|
||||
|
||||
return " ".join(parts) if parts else None
|
||||
|
|
Loading…
Reference in a new issue