diff --git a/conservancy/podjango/templatetags/date_within.py b/conservancy/podjango/templatetags/date_within.py new file mode 100644 index 0000000000000000000000000000000000000000..207bca71c7f74095ea29581ad2809219711ee6cf --- /dev/null +++ b/conservancy/podjango/templatetags/date_within.py @@ -0,0 +1,10 @@ +from datetime import datetime, timedelta + +from django import template + +register = template.Library() + +@register.filter +def date_within_past_days(value, arg): + # question: does datetime.now() do a syscall each time is it called? + return value > (datetime.now() - timedelta(days=int(arg)))