Author: mtredinnick
Date: 2006-06-10 19:33:44 -0500 (Sat, 10 Jun 2006)
New Revision: 3117

Modified:
   django/trunk/django/template/defaultfilters.py
Log:
Fixed #2127 -- Made datetime filters fail silently when passed empty strings or
None. Thanks, Gary Wilson.


Modified: django/trunk/django/template/defaultfilters.py
===================================================================
--- django/trunk/django/template/defaultfilters.py      2006-06-08 15:15:27 UTC 
(rev 3116)
+++ django/trunk/django/template/defaultfilters.py      2006-06-11 00:33:44 UTC 
(rev 3117)
@@ -330,6 +330,8 @@
 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 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 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)
 
 ###################


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to