-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PASS IAE: Affichage de l'estimation de durée restante [GEN-228] #4434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 👍
e4e538d
to
8433b9c
Compare
8433b9c
to
d7aa909
Compare
def _get_human_readable_estimate(self, days): | ||
split = [] | ||
years = days // 365 | ||
if years: | ||
split.append(f"{years} an{pluralizefr(years)}") | ||
days = days % 365 | ||
months = days // 30 | ||
if months: | ||
split.append(f"{months} mois") | ||
if years: | ||
return "Environ " + " et ".join(split) | ||
days = days % 30 | ||
weeks = days // 7 | ||
if weeks: | ||
split.append(f"{weeks} semaine{pluralizefr(weeks)}") | ||
if months: | ||
return "Environ " + " et ".join(split) | ||
days = days % 7 | ||
if days: | ||
split.append(f"{days} jour{pluralizefr(days)}") | ||
return " et ".join(split) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça m'a fait penser au filtre Django timeuntil mais je pense qu'utiliser la fonction sous-jacente est encore mieux : https://github.com/django/django/blob/5dc17177c38662d6f4408258ee117cd80e0cb933/django/utils/timesince.py#L138-L142
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trop bien, je vais essayer de l'utiliser à la place.
J'ai juste un doute sur le "Environ" à mettre devant 🤔
🤔 Pourquoi ?
C'est plus facile à comprendre que "571 jours"
🍰 Comment ?
🚨 À vérifier
🏝️ Comment tester
💻 Captures d'écran