1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +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:
Malcolm Tredinnick
2008-08-26 08:08:55 +00:00
parent 61957df17f
commit 3111d7f60b
6 changed files with 53 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
"""
>>> from datetime import datetime, timedelta
>>> from django.utils.timesince import timesince
>>> from django.utils.timesince import timesince, timeuntil
>>> from django.utils.tzinfo import LocalTimezone, FixedOffset
>>> t = datetime(2007, 8, 14, 13, 46, 0)
@@ -74,4 +75,15 @@ u'0 minutes'
u'0 minutes'
>>> timesince(t, t-4*oneday-5*oneminute)
u'0 minutes'
# When using two different timezones.
>>> now = datetime.now()
>>> now_tz = datetime.now(LocalTimezone(now))
>>> now_tz_i = datetime.now(FixedOffset((3 * 60) + 15))
>>> timesince(now)
u'0 minutes'
>>> timesince(now_tz)
u'0 minutes'
>>> timeuntil(now_tz, now_tz_i)
u'0 minutes'
"""