From 9cd09e756262a1b758bbd86f73e6c631e55e9073 Mon Sep 17 00:00:00 2001 From: James Bennett Date: Wed, 10 Oct 2007 15:51:38 +0000 Subject: [PATCH] 0.91-bugfixes: Minor improvement to [6468 git-svn-id: http://code.djangoproject.com/svn/django/branches/0.91-bugfixes@6471 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/template/defaultfilters.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django/core/template/defaultfilters.py b/django/core/template/defaultfilters.py index 15ba2e771a..69362fa2fa 100644 --- a/django/core/template/defaultfilters.py +++ b/django/core/template/defaultfilters.py @@ -327,23 +327,25 @@ def get_digit(value, arg): # DATES # ################### +EMPTY_DATE_VALUES = (None, '') + def date(value, arg=DATE_FORMAT): "Formats a date according to the given format" - if not value: + if value in EMPTY_DATE_VALUES: return '' from django.utils.dateformat import format return format(value, arg) def time(value, arg=TIME_FORMAT): "Formats a time according to the given format" - if not value: + if value in EMPTY_DATE_VALUES: return '' from django.utils.dateformat import 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")' - if not value: + if value in EMPTY_DATE_VALUES: return '' from django.utils.timesince import timesince return timesince(value)