Browse files

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
  • Loading branch information...
1 parent 4fc6e51 commit bff39bfb8cbc43bbeb78897c76583ab942927a0a @malcolmt malcolmt committed Jun 11, 2006
Showing with 6 additions and 0 deletions.
  1. +6 −0 django/template/defaultfilters.py
View
6 django/template/defaultfilters.py
@@ -330,20 +330,26 @@ 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)
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)
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)
###################

0 comments on commit bff39bf

Please sign in to comment.