comparison test/test_dates.py @ 640:7dd13fd5d8ea

fixed some problems in date calculations (calendar.py doesn't handle over- and under-flow). Also, hour/minute/second intervals may now be more than 99 each.
author Richard Jones <richard@users.sourceforge.net>
date Thu, 21 Feb 2002 23:11:45 +0000
parents 3d61b5d2243e
children cfa460943d4d
comparison
equal deleted inserted replaced
639:2f3e82a69eb5 640:7dd13fd5d8ea
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 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" 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, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: test_dates.py,v 1.9 2002-02-21 06:57:39 richard Exp $ 18 # $Id: test_dates.py,v 1.10 2002-02-21 23:11:45 richard Exp $
19 19
20 import unittest, time 20 import unittest, time
21 21
22 from roundup.date import Date, Interval 22 from roundup.date import Date, Interval
23 23
68 ae(str(date), '%s-11-07.14:32:43'%y) 68 ae(str(date), '%s-11-07.14:32:43'%y)
69 date = Date("14:25", -5) 69 date = Date("14:25", -5)
70 ae(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d)) 70 ae(str(date), '%s-%02d-%02d.19:25:00'%(y, m, d))
71 date = Date("8:47:11", -5) 71 date = Date("8:47:11", -5)
72 ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d)) 72 ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
73 # TODO: assert something 73
74 Date() + Interval('- 2y 2m') 74 # now check calculations
75 date = Date('2000-01-01') + Interval('- 2y 2m')
76 ae(str(date), '1997-11-01.00:00:00')
77 date = Date('2000-01-01') + Interval('+ 2m')
78 ae(str(date), '2000-03-01.00:00:00')
79
80 date = Date('2000-01-01') + Interval('60d')
81 ae(str(date), '2000-03-01.00:00:00')
82 date = Date('2001-01-01') + Interval('60d')
83 ae(str(date), '2001-03-02.00:00:00')
84
85 date = Date('2000-02-28.23:59:59') + Interval('00:00:01')
86 ae(str(date), '2000-02-29.00:00:00')
87 date = Date('2001-02-28.23:59:59') + Interval('00:00:01')
88 ae(str(date), '2001-03-01.00:00:00')
89
90 date = Date('2000-02-28.23:58:59') + Interval('00:01:01')
91 ae(str(date), '2000-02-29.00:00:00')
92 date = Date('2001-02-28.23:58:59') + Interval('00:01:01')
93 ae(str(date), '2001-03-01.00:00:00')
94
95 date = Date('2000-02-28.22:58:59') + Interval('01:01:01')
96 ae(str(date), '2000-02-29.00:00:00')
97 date = Date('2001-02-28.22:58:59') + Interval('01:01:01')
98 ae(str(date), '2001-03-01.00:00:00')
99
100 date = Date('2000-02-28.22:58:59') + Interval('00:00:3661')
101 ae(str(date), '2000-02-29.00:00:00')
102 date = Date('2001-02-28.22:58:59') + Interval('00:00:3661')
103 ae(str(date), '2001-03-01.00:00:00')
75 104
76 def testInterval(self): 105 def testInterval(self):
77 ae = self.assertEqual 106 ae = self.assertEqual
78 ae(str(Interval('3y')), '+ 3y') 107 ae(str(Interval('3y')), '+ 3y')
79 ae(str(Interval('2 y 1 m')), '+ 2y 1m') 108 ae(str(Interval('2 y 1 m')), '+ 2y 1m')
87 return unittest.makeSuite(DateTestCase, 'test') 116 return unittest.makeSuite(DateTestCase, 'test')
88 117
89 118
90 # 119 #
91 # $Log: not supported by cvs2svn $ 120 # $Log: not supported by cvs2svn $
121 # Revision 1.9 2002/02/21 06:57:39 richard
122 # . Added popup help for classes using the classhelp html template function.
123 # - add <display call="classhelp('priority', 'id,name,description')">
124 # to an item page, and it generates a link to a popup window which displays
125 # the id, name and description for the priority class. The description
126 # field won't exist in most installations, but it will be added to the
127 # default templates.
128 #
92 # Revision 1.8 2002/01/16 07:02:57 richard 129 # Revision 1.8 2002/01/16 07:02:57 richard
93 # . lots of date/interval related changes: 130 # . lots of date/interval related changes:
94 # - more relaxed date format for input 131 # - more relaxed date format for input
95 # 132 #
96 # Revision 1.7 2001/08/13 23:01:53 richard 133 # Revision 1.7 2001/08/13 23:01:53 richard

Roundup Issue Tracker: http://roundup-tracker.org/