Fix plural

This commit is contained in:
Benjamin Collet 2025-01-20 21:05:47 +01:00
parent 493a9dab30
commit 27a39e6bbc
Signed by: bcollet
SSH key fingerprint: SHA256:8UJspOIcCOS+MtSOcnuq2HjKFube4ox1s/+A62ixov4

View file

@ -10,18 +10,16 @@ from models import ssh_cert, x509_cert
def delta_text(delta):
if delta < timedelta(days=-2):
return f"in {abs(delta.days)} days"
elif delta < timedelta(days=-1):
return f"in {abs(delta.days)} day"
s = 's'[:abs(delta.days)^1]
if delta < timedelta(days=-1):
return f"in {abs(delta.days)} day{s}"
elif delta < timedelta(days=0):
return "in less than a day"
elif delta < timedelta(days=1):
return "less than a day ago"
elif delta < timedelta(days=2):
return f"{delta.days} day ago"
else:
return f"{delta.days} days ago"
return f"{delta.days} day{s} ago"
def list_ssh_certs(sort_key, revoked=False, expired=False):