mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #7201 -- Fixed the timeuntil filter to work correctly with timezone-aware
times. Patch from Jeremy Carbaugh. This is backwards incompatible in the sense that previously, if you tried to compare timezone-aware and timezone-naive values, you got an incorrect result. Now you get an empty string. So your previously incorrect code returns a different incorrect result. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8579 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -646,20 +646,24 @@ def timesince(value, arg=None):
|
||||
from django.utils.timesince import timesince
|
||||
if not value:
|
||||
return u''
|
||||
if arg:
|
||||
return timesince(value, arg)
|
||||
return timesince(value)
|
||||
try:
|
||||
if arg:
|
||||
return timesince(value, arg)
|
||||
return timesince(value)
|
||||
except (ValueError, TypeError):
|
||||
return u''
|
||||
timesince.is_safe = False
|
||||
|
||||
def timeuntil(value, arg=None):
|
||||
"""Formats a date as the time until that date (i.e. "4 days, 6 hours")."""
|
||||
from django.utils.timesince import timesince
|
||||
from django.utils.timesince import timeuntil
|
||||
from datetime import datetime
|
||||
if not value:
|
||||
return u''
|
||||
if arg:
|
||||
return timesince(arg, value)
|
||||
return timesince(datetime.now(), value)
|
||||
try:
|
||||
return timeuntil(value, arg)
|
||||
except (ValueError, TypeError):
|
||||
return u''
|
||||
timeuntil.is_safe = False
|
||||
|
||||
###################
|
||||
|
||||
Reference in New Issue
Block a user