Code

a8c79ea97fe5295a21420016b72481dd730d4087
[roundup.git] / test / test_dates.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 #
18 # $Id: test_dates.py,v 1.45 2008-03-07 01:11:55 richard Exp $
19 from __future__ import nested_scopes
21 import unittest
22 import time
23 import datetime
24 import calendar
26 from roundup.date import Date, Interval, Range, fixTimeOverflow, \
27     get_timezone
30 class DateTestCase(unittest.TestCase):
32     def testDateInterval(self):
33         ae = self.assertEqual
34         date = Date("2000-06-26.00:34:02 + 2d")
35         ae(str(date), '2000-06-28.00:34:02')
36         date = Date("2000-02-27 + 2d")
37         ae(str(date), '2000-02-29.00:00:00')
38         date = Date("2001-02-27 + 2d")
39         ae(str(date), '2001-03-01.00:00:00')
41     def testDate(self):
42         ae = self.assertEqual
43         date = Date("2000-04-17")
44         ae(str(date), '2000-04-17.00:00:00')
45         date = Date("2000/04/17")
46         ae(str(date), '2000-04-17.00:00:00')
47         date = Date("2000-4-7")
48         ae(str(date), '2000-04-07.00:00:00')
49         date = Date("2000-4-17")
50         ae(str(date), '2000-04-17.00:00:00')
51         date = Date("01-25")
52         y, m, d, x, x, x, x, x, x = time.gmtime(time.time())
53         ae(str(date), '%s-01-25.00:00:00'%y)
54         date = Date("2000-04-17.03:45")
55         ae(str(date), '2000-04-17.03:45:00')
56         date = Date("2000/04/17.03:45")
57         ae(str(date), '2000-04-17.03:45:00')
58         date = Date("08-13.22:13")
59         ae(str(date), '%s-08-13.22:13:00'%y)
60         date = Date("11-07.09:32:43")
61         ae(str(date), '%s-11-07.09:32:43'%y)
62         date = Date("14:25")
63         ae(str(date), '%s-%02d-%02d.14:25:00'%(y, m, d))
64         date = Date("8:47:11")
65         ae(str(date), '%s-%02d-%02d.08:47:11'%(y, m, d))
66         ae(str(Date('2003')), '2003-01-01.00:00:00')
67         ae(str(Date('2004-06')), '2004-06-01.00:00:00')
68         ae(str(Date('1900-02-01')), '1900-02-01.00:00:00')
69         ae(str(Date('1800-07-15')), '1800-07-15.00:00:00')
71     def testLeapYear(self):
72         self.assertEquals(str(Date('2008-02-29')), '2008-02-29.00:00:00')
74     def testDateError(self):
75         self.assertRaises(ValueError, Date, "12")
76         # Date cannot handle dates before year 1
77         self.assertRaises(ValueError, Date, (0, 1, 1, 0, 0, 0.0, 0, 1, -1))
78         self.assertRaises(ValueError, Date, "1/1/06")
80     def testOffset(self):
81         ae = self.assertEqual
82         date = Date("2000-04-17", -5)
83         ae(str(date), '2000-04-17.05:00:00')
84         date = Date("01-25", -5)
85         y, m, d, x, x, x, x, x, x = time.gmtime(time.time())
86         ae(str(date), '%s-01-25.05:00:00'%y)
87         date = Date("2000-04-17.03:45", -5)
88         ae(str(date), '2000-04-17.08:45:00')
89         date = Date("08-13.22:13", -5)
90         ae(str(date), '%s-08-14.03:13:00'%y)
91         date = Date("11-07.09:32:43", -5)
92         ae(str(date), '%s-11-07.14:32:43'%y)
93         date = Date("14:25", -5)
94         ae(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
95         date = Date("8:47:11", -5)
96         ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
98         # just make sure we parse these, m'kay?
99         date = Date('-1d')
100         date = Date('-1w')
101         date = Date('-1m')
102         date = Date('-1y')
104     def testOffsetRandom(self):
105         ae = self.assertEqual
106         # XXX unsure of the usefulness of these, they're pretty random
107         date = Date('2000-01-01') + Interval('- 2y 2m')
108         ae(str(date), '1997-11-01.00:00:00')
109         date = Date('2000-01-01 - 2y 2m')
110         ae(str(date), '1997-11-01.00:00:00')
111         date = Date('2000-01-01') + Interval('2m')
112         ae(str(date), '2000-03-01.00:00:00')
113         date = Date('2000-01-01 + 2m')
114         ae(str(date), '2000-03-01.00:00:00')
116         date = Date('2000-01-01') + Interval('60d')
117         ae(str(date), '2000-03-01.00:00:00')
118         date = Date('2001-01-01') + Interval('60d')
119         ae(str(date), '2001-03-02.00:00:00')
121     def testOffsetAdd(self):
122         ae = self.assertEqual
123         date = Date('2000-02-28.23:59:59') + Interval('00:00:01')
124         ae(str(date), '2000-02-29.00:00:00')
125         date = Date('2001-02-28.23:59:59') + Interval('00:00:01')
126         ae(str(date), '2001-03-01.00:00:00')
128         date = Date('2000-02-28.23:58:59') + Interval('00:01:01')
129         ae(str(date), '2000-02-29.00:00:00')
130         date = Date('2001-02-28.23:58:59') + Interval('00:01:01')
131         ae(str(date), '2001-03-01.00:00:00')
133         date = Date('2000-02-28.22:58:59') + Interval('01:01:01')
134         ae(str(date), '2000-02-29.00:00:00')
135         date = Date('2001-02-28.22:58:59') + Interval('01:01:01')
136         ae(str(date), '2001-03-01.00:00:00')
138         date = Date('2000-02-28.22:58:59') + Interval('00:00:3661')
139         ae(str(date), '2000-02-29.00:00:00')
140         date = Date('2001-02-28.22:58:59') + Interval('00:00:3661')
141         ae(str(date), '2001-03-01.00:00:00')
142         date = Date('2001-03-01.00:00:00') + Interval('150y')
143         ae(str(date), '2151-03-01.00:00:00')
145     def testOffsetSub(self):
146         ae = self.assertEqual
147         date = Date('2000-12-01') - Interval('- 1d')
149         date = Date('2000-01-01') - Interval('- 2y 2m')
150         ae(str(date), '2002-03-01.00:00:00')
151         date = Date('2000-01-01') - Interval('2m')
152         ae(str(date), '1999-11-01.00:00:00')
154         date = Date('2000-03-01') - Interval('60d')
155         ae(str(date), '2000-01-01.00:00:00')
156         date = Date('2001-03-02') - Interval('60d')
157         ae(str(date), '2001-01-01.00:00:00')
159         date = Date('2000-02-29.00:00:00') - Interval('00:00:01')
160         ae(str(date), '2000-02-28.23:59:59')
161         date = Date('2001-03-01.00:00:00') - Interval('00:00:01')
162         ae(str(date), '2001-02-28.23:59:59')
164         date = Date('2000-02-29.00:00:00') - Interval('00:01:01')
165         ae(str(date), '2000-02-28.23:58:59')
166         date = Date('2001-03-01.00:00:00') - Interval('00:01:01')
167         ae(str(date), '2001-02-28.23:58:59')
169         date = Date('2000-02-29.00:00:00') - Interval('01:01:01')
170         ae(str(date), '2000-02-28.22:58:59')
171         date = Date('2001-03-01.00:00:00') - Interval('01:01:01')
172         ae(str(date), '2001-02-28.22:58:59')
174         date = Date('2000-02-29.00:00:00') - Interval('00:00:3661')
175         ae(str(date), '2000-02-28.22:58:59')
176         date = Date('2001-03-01.00:00:00') - Interval('00:00:3661')
177         ae(str(date), '2001-02-28.22:58:59')
178         date = Date('2001-03-01.00:00:00') - Interval('150y')
179         ae(str(date), '1851-03-01.00:00:00')
181     def testDateLocal(self):
182         ae = self.assertEqual
183         date = Date("02:42:20")
184         date = date.local(10)
185         y, m, d, x, x, x, x, x, x = time.gmtime(time.time())
186         ae(str(date), '%s-%02d-%02d.12:42:20'%(y, m, d))
188     def testIntervalInit(self):
189         ae = self.assertEqual
190         ae(str(Interval('3y')), '+ 3y')
191         ae(str(Interval('2 y 1 m')), '+ 2y 1m')
192         ae(str(Interval('1m 25d')), '+ 1m 25d')
193         ae(str(Interval('-2w 3 d ')), '- 17d')
194         ae(str(Interval(' - 1 d 2:50 ')), '- 1d 2:50')
195         ae(str(Interval(' 14:00 ')), '+ 14:00')
196         ae(str(Interval(' 0:04:33 ')), '+ 0:04:33')
197         ae(str(Interval(8.*3600)), '+ 8:00')
199     def testIntervalInitDate(self):
200         ae = self.assertEqual
201         now = Date('.')
202         now.hour = now.minute = now.second = 0
203         then = now + Interval('2d')
204         ae((Interval(str(then))), Interval('- 2d'))
205         then = now - Interval('2d')
206         ae(Interval(str(then)), Interval('+ 2d'))
208     def testIntervalAddMonthBoundary(self):
209         # force the transition over a month boundary
210         now = Date('2003-10-30.00:00:00')
211         then = now + Interval('2d')
212         self.assertEqual(str(then), '2003-11-01.00:00:00')
213         now = Date('2004-02-28.00:00:00')
214         then = now + Interval('1d')
215         self.assertEqual(str(then), '2004-02-29.00:00:00')
216         now = Date('2003-02-28.00:00:00')
217         then = now + Interval('1d')
218         self.assertEqual(str(then), '2003-03-01.00:00:00')
219         now = Date('2003-01-01.00:00:00')
220         then = now + Interval('59d')
221         self.assertEqual(str(then), '2003-03-01.00:00:00')
222         now = Date('2004-01-01.00:00:00')
223         then = now + Interval('59d')
224         self.assertEqual(str(then), '2004-02-29.00:00:00')
226     def testIntervalSubtractMonthBoundary(self):
227         # force the transition over a month boundary
228         now = Date('2003-11-01.00:00:00')
229         then = now - Interval('2d')
230         self.assertEqual(str(then), '2003-10-30.00:00:00')
231         now = Date('2004-02-29.00:00:00')
232         then = now - Interval('1d')
233         self.assertEqual(str(then), '2004-02-28.00:00:00')
234         now = Date('2003-03-01.00:00:00')
235         then = now - Interval('1d')
236         self.assertEqual(str(then), '2003-02-28.00:00:00')
237         now = Date('2003-03-01.00:00:00')
238         then = now - Interval('59d')
239         self.assertEqual(str(then), '2003-01-01.00:00:00')
240         now = Date('2004-02-29.00:00:00')
241         then = now - Interval('59d')
242         self.assertEqual(str(then), '2004-01-01.00:00:00')
244     def testIntervalAddYearBoundary(self):
245         # force the transition over a year boundary
246         now = Date('2003-12-30.00:00:00')
247         then = now + Interval('2d')
248         self.assertEqual(str(then), '2004-01-01.00:00:00')
249         now = Date('2003-01-01.00:00:00')
250         then = now + Interval('365d')
251         self.assertEqual(str(then), '2004-01-01.00:00:00')
252         now = Date('2004-01-01.00:00:00')
253         then = now + Interval('366d')
254         self.assertEqual(str(then), '2005-01-01.00:00:00')
256     def testIntervalSubtractYearBoundary(self):
257         # force the transition over a year boundary
258         now = Date('2003-01-01.00:00:00')
259         then = now - Interval('2d')
260         self.assertEqual(str(then), '2002-12-30.00:00:00')
261         now = Date('2004-02-01.00:00:00')
262         then = now - Interval('365d')
263         self.assertEqual(str(then), '2003-02-01.00:00:00')
264         now = Date('2005-02-01.00:00:00')
265         then = now - Interval('365d')
266         self.assertEqual(str(then), '2004-02-02.00:00:00')
268     def testDateSubtract(self):
269         # These are thoroughly broken right now.
270         i = Date('2003-03-15.00:00:00') - Date('2003-03-10.00:00:00')
271         self.assertEqual(i, Interval('5d'))
272         i = Date('2003-02-01.00:00:00') - Date('2003-03-01.00:00:00')
273         self.assertEqual(i, Interval('-28d'))
274         i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00')
275         self.assertEqual(i, Interval('28d'))
276         i = Date('2003-03-03.00:00:00') - Date('2003-02-01.00:00:00')
277         self.assertEqual(i, Interval('30d'))
278         i = Date('2003-03-03.00:00:00') - Date('2002-02-01.00:00:00')
279         self.assertEqual(i, Interval('395d'))
280         i = Date('2003-03-03.00:00:00') - Date('2003-04-01.00:00:00')
281         self.assertEqual(i, Interval('-29d'))
282         i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00')
283         self.assertEqual(i, Interval('28d'))
284         # force the transition over a year boundary
285         i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00')
286         self.assertEqual(i, Interval('365d'))
287         i = Date('1952-01-01') - Date('1953-01-01')
288         self.assertEqual(i, Interval('-366d'))
289         i = Date('1953-01-01') - Date('1952-01-01')
290         self.assertEqual(i, Interval('366d'))
292     def testIntervalAdd(self):
293         ae = self.assertEqual
294         ae(str(Interval('1y') + Interval('1y')), '+ 2y')
295         ae(str(Interval('1y') + Interval('1m')), '+ 1y 1m')
296         ae(str(Interval('1y') + Interval('2:40')), '+ 1y 2:40')
297         ae(str(Interval('1y') + Interval('- 1y')), '00:00')
298         ae(str(Interval('- 1y') + Interval('1y')), '00:00')
299         ae(str(Interval('- 1y') + Interval('- 1y')), '- 2y')
300         ae(str(Interval('1y') + Interval('- 1m')), '+ 11m')
301         ae(str(Interval('1:00') + Interval('1:00')), '+ 2:00')
302         ae(str(Interval('0:50') + Interval('0:50')), '+ 1:40')
303         ae(str(Interval('1:50') + Interval('- 1:50')), '00:00')
304         ae(str(Interval('- 1:50') + Interval('1:50')), '00:00')
305         ae(str(Interval('- 1:50') + Interval('- 1:50')), '- 3:40')
306         ae(str(Interval('1:59:59') + Interval('00:00:01')), '+ 2:00')
307         ae(str(Interval('2:00') + Interval('- 00:00:01')), '+ 1:59:59')
309     def testIntervalSub(self):
310         ae = self.assertEqual
311         ae(str(Interval('1y') - Interval('- 1y')), '+ 2y')
312         ae(str(Interval('1y') - Interval('- 1m')), '+ 1y 1m')
313         ae(str(Interval('1y') - Interval('- 2:40')), '+ 1y 2:40')
314         ae(str(Interval('1y') - Interval('1y')), '00:00')
315         ae(str(Interval('1y') - Interval('1m')), '+ 11m')
316         ae(str(Interval('1:00') - Interval('- 1:00')), '+ 2:00')
317         ae(str(Interval('0:50') - Interval('- 0:50')), '+ 1:40')
318         ae(str(Interval('1:50') - Interval('1:50')), '00:00')
319         ae(str(Interval('1:59:59') - Interval('- 00:00:01')), '+ 2:00')
320         ae(str(Interval('2:00') - Interval('00:00:01')), '+ 1:59:59')
322     def testOverflow(self):
323         ae = self.assertEqual
324         ae(fixTimeOverflow((1,0,0,0, 0, 0, 60)), (1,0,0,0, 0, 1, 0))
325         ae(fixTimeOverflow((1,0,0,0, 0, 0, 100)), (1,0,0,0, 0, 1, 40))
326         ae(fixTimeOverflow((1,0,0,0, 0, 0, 60*60)), (1,0,0,0, 1, 0, 0))
327         ae(fixTimeOverflow((1,0,0,0, 0, 0, 24*60*60)), (1,0,0,1, 0, 0, 0))
328         ae(fixTimeOverflow((1,0,0,0, 0, 0, -1)), (-1,0,0,0, 0, 0, 1))
329         ae(fixTimeOverflow((1,0,0,0, 0, 0, -100)), (-1,0,0,0, 0, 1, 40))
330         ae(fixTimeOverflow((1,0,0,0, 0, 0, -60*60)), (-1,0,0,0, 1, 0, 0))
331         ae(fixTimeOverflow((1,0,0,0, 0, 0, -24*60*60)), (-1,0,0,1, 0, 0, 0))
332         ae(fixTimeOverflow((-1,0,0,0, 0, 0, 1)), (-1,0,0,0, 0, 0, 1))
333         ae(fixTimeOverflow((-1,0,0,0, 0, 0, 100)), (-1,0,0,0, 0, 1, 40))
334         ae(fixTimeOverflow((-1,0,0,0, 0, 0, 60*60)), (-1,0,0,0, 1, 0, 0))
335         ae(fixTimeOverflow((-1,0,0,0, 0, 0, 24*60*60)), (-1,0,0,1, 0, 0, 0))
337     def testDivision(self):
338         ae = self.assertEqual
339         ae(str(Interval('1y')/2), '+ 6m')
340         ae(str(Interval('1:00')/2), '+ 0:30')
341         ae(str(Interval('00:01')/2), '+ 0:00:30')
343     def testSorting(self):
344         ae = self.assertEqual
345         i1 = Interval('1y')
346         i2 = Interval('1d')
347         l = [i1, i2]; l.sort()
348         ae(l, [i2, i1])
349         l = [i2, i1]; l.sort()
350         ae(l, [i2, i1])
351         i1 = Interval('- 2d')
352         i2 = Interval('1d')
353         l = [i1, i2]; l.sort()
354         ae(l, [i1, i2])
356         i1 = Interval("1:20")
357         i2 = Interval("2d")
358         i3 = Interval("3:30")
359         l = [i1, i2, i3]; l.sort()
360         ae(l, [i1, i3, i2])
362     def testGranularity(self):
363         ae = self.assertEqual
364         ae(str(Date('2003-2-12', add_granularity=1)), '2003-02-12.23:59:59')
365         ae(str(Date('2003-1-1.23:00', add_granularity=1)), '2003-01-01.23:00:59')
366         ae(str(Date('2003', add_granularity=1)), '2003-12-31.23:59:59')
367         ae(str(Date('2003-5', add_granularity=1)), '2003-05-31.23:59:59')
368         ae(str(Date('2003-12', add_granularity=1)), '2003-12-31.23:59:59')
369         ae(str(Interval('+1w', add_granularity=1)), '+ 14d')
370         ae(str(Interval('-2m 3w', add_granularity=1)), '- 2m 14d')
372     def testIntervalPretty(self):
373         def ae(spec, pretty):
374             self.assertEqual(Interval(spec).pretty(), pretty)
375         ae('2y', 'in 2 years')
376         ae('1y', 'in 1 year')
377         ae('2m', 'in 2 months')
378         ae('1m 30d', 'in 2 months')
379         ae('60d', 'in 2 months')
380         ae('59d', 'in 1 month')
381         ae('1m', 'in 1 month')
382         ae('29d', 'in 1 month')
383         ae('28d', 'in 4 weeks')
384         ae('8d', 'in 1 week')
385         ae('7d', 'in 7 days')
386         ae('1w', 'in 7 days')
387         ae('2d', 'in 2 days')
388         ae('1d', 'tomorrow')
389         ae('02:00:00', 'in 2 hours')
390         ae('01:59:00', 'in 1 3/4 hours')
391         ae('01:45:00', 'in 1 3/4 hours')
392         ae('01:30:00', 'in 1 1/2 hours')
393         ae('01:29:00', 'in 1 1/4 hours')
394         ae('01:00:00', 'in an hour')
395         ae('00:30:00', 'in 1/2 an hour')
396         ae('00:15:00', 'in 1/4 hour')
397         ae('00:02:00', 'in 2 minutes')
398         ae('00:01:00', 'in 1 minute')
399         ae('00:00:30', 'in a moment')
400         ae('-00:00:30', 'just now')
401         ae('-1d', 'yesterday')
402         ae('-1y', '1 year ago')
403         ae('-2y', '2 years ago')
405     def testPyDatetime(self):
406         d = datetime.datetime.now()
407         Date(d)
408         toomuch = datetime.MAXYEAR + 1
409         self.assertRaises(ValueError, Date, (toomuch, 1, 1, 0, 0, 0, 0, 1, -1))
411     def testSimpleTZ(self):
412         ae = self.assertEqual
413         # local to utc
414         date = Date('2006-04-04.12:00:00', 2)
415         ae(str(date), '2006-04-04.10:00:00')
416         # utc to local
417         date = Date('2006-04-04.10:00:00')
418         date = date.local(2)
419         ae(str(date), '2006-04-04.12:00:00')
420         # from Date instance
421         date = Date('2006-04-04.12:00:00')
422         date = Date(date, 2)
423         ae(str(date), '2006-04-04.10:00:00')
425     def testTimestamp(self):
426         ae = self.assertEqual
427         date = Date('2038')
428         ae(date.timestamp(), 2145916800)
429         date = Date('1902')
430         ae(date.timestamp(), -2145916800)
431         date = Date(time.gmtime(0))
432         ae(date.timestamp(), 0)
433         ae(str(date), '1970-01-01.00:00:00')
434         date = Date(time.gmtime(0x7FFFFFFF))
435         ae(date.timestamp(), 2147483647)
436         ae(str(date), '2038-01-19.03:14:07')
437         date = Date('1901-12-13.20:45:52')
438         ae(date.timestamp(), -0x80000000L)
439         ae(str(date), '1901-12-13.20:45:52')
440         date = Date('9999')
441         ae (date.timestamp(), 253370764800.0)
442         date = Date('0033')
443         ae (date.timestamp(), -61125753600.0)
444         ae(str(date), '0033-01-01.00:00:00')
446 class TimezoneTestCase(unittest.TestCase):
448     def testTZ(self):
449         ae = self.assertEqual
450         tz = 'Europe/Warsaw'
452         # local to utc, DST
453         date = Date('2006-04-04.12:00:00', tz)
454         ae(str(date), '2006-04-04.10:00:00')
456         # local to utc, no DST
457         date = Date('2006-01-01.12:00:00', tz)
458         ae(str(date), '2006-01-01.11:00:00')
460         # utc to local, DST
461         date = Date('2006-04-04.10:00:00')
462         date = date.local(tz)
463         ae(str(date), '2006-04-04.12:00:00')
465         # utc to local, no DST
466         date = Date('2006-01-01.10:00:00')
467         date = date.local(tz)
468         ae(str(date), '2006-01-01.11:00:00')
470         date = Date('2006-04-04.12:00:00')
471         date = Date(date, tz)
472         ae(str(date), '2006-04-04.10:00:00')
473         date = Date('2006-01-01.12:00:00')
474         date = Date(date, tz)
475         ae(str(date), '2006-01-01.11:00:00')
478 class RangeTestCase(unittest.TestCase):
480     def testRange(self):
481         ae = self.assertEqual
482         r = Range('2006', Date)
483         ae(str(r.from_value), '2006-01-01.00:00:00')
484         ae(str(r.to_value), '2006-12-31.23:59:59')
485         for i in range(1, 13):
486             r = Range('2006-%02d'%i, Date)
487             ae(str(r.from_value), '2006-%02d-01.00:00:00'%i)
488             ae(str(r.to_value), '2006-%02d-%02d.23:59:59'%(i,
489                 calendar.mdays[i]))
492 def test_suite():
493     suite = unittest.TestSuite()
494     suite.addTest(unittest.makeSuite(DateTestCase))
495     suite.addTest(unittest.makeSuite(RangeTestCase))
496     try:
497         import pytz
498     except ImportError:
499         pass
500     else:
501         suite.addTest(unittest.makeSuite(TimezoneTestCase))
502     return suite
504 if __name__ == '__main__':
505     runner = unittest.TextTestRunner()
506     unittest.main(testRunner=runner)
508 # vim: set filetype=python sts=4 sw=4 et si :