1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00

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
This commit is contained in:
Malcolm Tredinnick 2006-06-11 00:33:44 +00:00
parent 4fc6e51706
commit bff39bfb8c

View File

@ -330,6 +330,8 @@ def get_digit(value, arg):
def date(value, arg=None): def date(value, arg=None):
"Formats a date according to the given format" "Formats a date according to the given format"
from django.utils.dateformat import format from django.utils.dateformat import format
if not value:
return ''
if arg is None: if arg is None:
arg = settings.DATE_FORMAT arg = settings.DATE_FORMAT
return format(value, arg) return format(value, arg)
@ -337,6 +339,8 @@ def date(value, arg=None):
def time(value, arg=None): def time(value, arg=None):
"Formats a time according to the given format" "Formats a time according to the given format"
from django.utils.dateformat import time_format from django.utils.dateformat import time_format
if not value:
return ''
if arg is None: if arg is None:
arg = settings.TIME_FORMAT arg = settings.TIME_FORMAT
return time_format(value, arg) return time_format(value, arg)
@ -344,6 +348,8 @@ def time(value, arg=None):
def timesince(value): def timesince(value):
'Formats a date as the time since that date (i.e. "4 days, 6 hours")' 'Formats a date as the time since that date (i.e. "4 days, 6 hours")'
from django.utils.timesince import timesince from django.utils.timesince import timesince
if not value:
return ''
return timesince(value) return timesince(value)
################### ###################