summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-06-11 00:33:44 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-06-11 00:33:44 +0000
commitbff39bfb8cbc43bbeb78897c76583ab942927a0a (patch)
tree51ec2c3ddbad9dd0b02f5d6e3d9b45b69bb3d7df
parent4fc6e517061a0c766bd7b00411d15fb1bdc6e856 (diff)
Fixed #2127 -- Made datetime filters fail silently when passed empty strings or
None. Thanks, Gary Wilson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3117 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/defaultfilters.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 03069121ee..453c34b0bd 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -330,6 +330,8 @@ def get_digit(value, arg):
def date(value, arg=None):
"Formats a date according to the given format"
from django.utils.dateformat import format
+ if not value:
+ return ''
if arg is None:
arg = settings.DATE_FORMAT
return format(value, arg)
@@ -337,6 +339,8 @@ def date(value, arg=None):
def time(value, arg=None):
"Formats a time according to the given format"
from django.utils.dateformat import time_format
+ if not value:
+ return ''
if arg is None:
arg = settings.TIME_FORMAT
return time_format(value, arg)
@@ -344,6 +348,8 @@ def time(value, arg=None):
def timesince(value):
'Formats a date as the time since that date (i.e. "4 days, 6 hours")'
from django.utils.timesince import timesince
+ if not value:
+ return ''
return timesince(value)
###################