summaryrefslogtreecommitdiffstats
path: root/activities/templatetags
diff options
context:
space:
mode:
authorMichael Manfre2022-11-20 13:14:49 -0500
committerGitHub2022-11-20 11:14:49 -0700
commitf8f4fa8665ef61caf5266c980046305f3b779c6d (patch)
treedb66d7e5e83b6d828db38f246b154e75a0d087b2 /activities/templatetags
parent6b7082a194a19579430e426ffc4bce52ffd336e9 (diff)
downloadtakahe-f8f4fa8665ef61caf5266c980046305f3b779c6d.tar.gz
takahe-f8f4fa8665ef61caf5266c980046305f3b779c6d.tar.bz2
takahe-f8f4fa8665ef61caf5266c980046305f3b779c6d.zip
Fix bug in timedeltashort and add tests
Diffstat (limited to 'activities/templatetags')
-rw-r--r--activities/templatetags/activity_tags.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/activities/templatetags/activity_tags.py b/activities/templatetags/activity_tags.py
index cbbae57..571e2d6 100644
--- a/activities/templatetags/activity_tags.py
+++ b/activities/templatetags/activity_tags.py
@@ -26,8 +26,8 @@ def timedeltashort(value: datetime.datetime):
hours = seconds // (60 * 60)
text = f"{hours:0n}h"
elif days < 365:
- text = f"{days:0n}h"
+ text = f"{days:0n}d"
else:
- years = days // 365.25
+ years = max(days // 365.25, 1)
text = f"{years:0n}y"
return text