Added some tests to show that #9672 has been fixed ever since [10215]. Refs #9672.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-04-07 22:12:53 +00:00
parent 6d6bbb6d05
commit bbe37492dc
1 changed files with 22 additions and 13 deletions

View File

@ -1,18 +1,18 @@
""" """
>>> from datetime import datetime, timedelta >>> import datetime
>>> from django.utils.timesince import timesince, timeuntil >>> from django.utils.timesince import timesince, timeuntil
>>> from django.utils.tzinfo import LocalTimezone, FixedOffset >>> from django.utils.tzinfo import LocalTimezone, FixedOffset
>>> t = datetime(2007, 8, 14, 13, 46, 0) >>> t = datetime.datetime(2007, 8, 14, 13, 46, 0)
>>> onemicrosecond = timedelta(microseconds=1) >>> onemicrosecond = datetime.timedelta(microseconds=1)
>>> onesecond = timedelta(seconds=1) >>> onesecond = datetime.timedelta(seconds=1)
>>> oneminute = timedelta(minutes=1) >>> oneminute = datetime.timedelta(minutes=1)
>>> onehour = timedelta(hours=1) >>> onehour = datetime.timedelta(hours=1)
>>> oneday = timedelta(days=1) >>> oneday = datetime.timedelta(days=1)
>>> oneweek = timedelta(days=7) >>> oneweek = datetime.timedelta(days=7)
>>> onemonth = timedelta(days=30) >>> onemonth = datetime.timedelta(days=30)
>>> oneyear = timedelta(days=365) >>> oneyear = datetime.timedelta(days=365)
# equal datetimes. # equal datetimes.
>>> timesince(t, t) >>> timesince(t, t)
@ -77,13 +77,22 @@ u'0 minutes'
u'0 minutes' u'0 minutes'
# When using two different timezones. # When using two different timezones.
>>> now = datetime.now() >>> now = datetime.datetime.now()
>>> now_tz = datetime.now(LocalTimezone(now)) >>> now_tz = datetime.datetime.now(LocalTimezone(now))
>>> now_tz_i = datetime.now(FixedOffset((3 * 60) + 15)) >>> now_tz_i = datetime.datetime.now(FixedOffset((3 * 60) + 15))
>>> timesince(now) >>> timesince(now)
u'0 minutes' u'0 minutes'
>>> timesince(now_tz) >>> timesince(now_tz)
u'0 minutes' u'0 minutes'
>>> timeuntil(now_tz, now_tz_i) >>> timeuntil(now_tz, now_tz_i)
u'0 minutes' u'0 minutes'
# Timesince should work with both date objects (#9672)
>>> today = datetime.date.today()
>>> timeuntil(today+oneday, today)
u'1 day'
>>> timeuntil(today-oneday, today)
u'0 minutes'
>>> timeuntil(today+oneweek, today)
u'1 week'
""" """