Code

Ticket #2053: timeslice.diff

File timeslice.diff, 939 bytes (added by john@…, 8 years ago)

[patch] for this ticket.

Line 
1Index: django/template/defaultfilters.py
2===================================================================
3--- django/template/defaultfilters.py   (revision 3008)
4+++ django/template/defaultfilters.py   (working copy)
5@@ -341,11 +341,23 @@
6         arg = settings.TIME_FORMAT
7     return time_format(value, arg)
8 
9-def timesince(value):
10+def timesince(value, arg=None):
11     'Formats a date as the time since that date (i.e. "4 days, 6 hours")'
12     from django.utils.timesince import timesince
13-    return timesince(value)
14+    if arg:
15+        return timesince(arg, value)
16+    else:
17+        return timesince(value)
18 
19+def timeuntil(value, arg=None):
20+    'Formats a date as the time until that date (i.e. "4 days, 6 hours")'
21+    from django.utils.timesince import timeuntil
22+    if arg:
23+        return timeuntil(arg, value)
24+    else:
25+        return timeuntil(value)
26+
27+
28 ###################
29 # LOGIC           #
30 ###################