Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Added some tests to show that #9672 has been fixed ever since…

… [10215]. Refs #9672. Backport of r10440 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10441 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4f2259f539d530a8723de0c4b96544432e9bc83b 1 parent 806d898
Jacob Kaplan-Moss authored April 07, 2009

Showing 1 changed file with 22 additions and 13 deletions. Show diff stats Hide diff stats

  1. 35  tests/regressiontests/utils/timesince.py
35  tests/regressiontests/utils/timesince.py
... ...
@@ -1,18 +1,18 @@
1 1
 """
2  
->>> from datetime import datetime, timedelta
  2
+>>> import datetime
3 3
 >>> from django.utils.timesince import timesince, timeuntil
4 4
 >>> from django.utils.tzinfo import LocalTimezone, FixedOffset
5 5
 
6  
->>> t = datetime(2007, 8, 14, 13, 46, 0)
  6
+>>> t = datetime.datetime(2007, 8, 14, 13, 46, 0)
7 7
 
8  
->>> onemicrosecond = timedelta(microseconds=1)
9  
->>> onesecond = timedelta(seconds=1)
10  
->>> oneminute = timedelta(minutes=1)
11  
->>> onehour = timedelta(hours=1)
12  
->>> oneday = timedelta(days=1)
13  
->>> oneweek = timedelta(days=7)
14  
->>> onemonth = timedelta(days=30)
15  
->>> oneyear = timedelta(days=365)
  8
+>>> onemicrosecond = datetime.timedelta(microseconds=1)
  9
+>>> onesecond = datetime.timedelta(seconds=1)
  10
+>>> oneminute = datetime.timedelta(minutes=1)
  11
+>>> onehour = datetime.timedelta(hours=1)
  12
+>>> oneday = datetime.timedelta(days=1)
  13
+>>> oneweek = datetime.timedelta(days=7)
  14
+>>> onemonth = datetime.timedelta(days=30)
  15
+>>> oneyear = datetime.timedelta(days=365)
16 16
 
17 17
 # equal datetimes.
18 18
 >>> timesince(t, t)
@@ -77,13 +77,22 @@
77 77
 u'0 minutes'
78 78
 
79 79
 # When using two different timezones.
80  
->>> now = datetime.now()
81  
->>> now_tz = datetime.now(LocalTimezone(now))
82  
->>> now_tz_i = datetime.now(FixedOffset((3 * 60) + 15))
  80
+>>> now = datetime.datetime.now()
  81
+>>> now_tz = datetime.datetime.now(LocalTimezone(now))
  82
+>>> now_tz_i = datetime.datetime.now(FixedOffset((3 * 60) + 15))
83 83
 >>> timesince(now)
84 84
 u'0 minutes'
85 85
 >>> timesince(now_tz)
86 86
 u'0 minutes'
87 87
 >>> timeuntil(now_tz, now_tz_i)
88 88
 u'0 minutes'
  89
+
  90
+# Timesince should work with both date objects (#9672)
  91
+>>> today = datetime.date.today() 
  92
+>>> timeuntil(today+oneday, today) 
  93
+u'1 day' 
  94
+>>> timeuntil(today-oneday, today) 
  95
+u'0 minutes' 
  96
+>>> timeuntil(today+oneweek, today) 
  97
+u'1 week' 
89 98
 """

0 notes on commit 4f2259f

Please sign in to comment.
Something went wrong with that request. Please try again.