comparison test/test_dates.py @ 1894:41ad8b781232

Date - Date works again. Note that it only produces Intervals with days, hours, minutes and seconds. Making it produce years and months is a lot more work. bugfix candidate
author Anthony Baxter <anthonybaxter@users.sourceforge.net>
date Tue, 04 Nov 2003 12:35:47 +0000
parents e3cff1bb1b86
children 71056b09f2bf
comparison
equal deleted inserted replaced
1893:cd53a3122657 1894:41ad8b781232
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.28 2003-11-03 10:33:23 anthonybaxter Exp $ 18 # $Id: test_dates.py,v 1.29 2003-11-04 12:35:47 anthonybaxter Exp $
19 19
20 import unittest, time 20 import unittest, time
21 21
22 from roundup.date import Date, Interval, Range, fixTimeOverflow 22 from roundup.date import Date, Interval, Range, fixTimeOverflow
23 23
171 def testIntervalInitDate(self): 171 def testIntervalInitDate(self):
172 ae = self.assertEqual 172 ae = self.assertEqual
173 now = Date('.') 173 now = Date('.')
174 now.hour = now.minute = now.second = 0 174 now.hour = now.minute = now.second = 0
175 then = now + Interval('2d') 175 then = now + Interval('2d')
176 ae(str(Interval(str(then))), '+ 2d') 176 ae((Interval(str(then))), Interval('- 2d'))
177 then = now - Interval('2d') 177 then = now - Interval('2d')
178 ae(str(Interval(str(then))), '- 2d') 178 ae(Interval(str(then)), Interval('+ 2d'))
179 179
180 def testIntervalAddMonthBoundary(self): 180 def testIntervalAddMonthBoundary(self):
181 # force the transition over a month boundary 181 # force the transition over a month boundary
182 now = Date('2003-10-30.00:00:00') 182 now = Date('2003-10-30.00:00:00')
183 then = now + Interval('2d') 183 then = now + Interval('2d')
243 self.assertEqual(i, Interval('5d')) 243 self.assertEqual(i, Interval('5d'))
244 i = Date('2003-02-01.00:00:00') - Date('2003-03-01.00:00:00') 244 i = Date('2003-02-01.00:00:00') - Date('2003-03-01.00:00:00')
245 self.assertEqual(i, Interval('-28d')) 245 self.assertEqual(i, Interval('-28d'))
246 i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00') 246 i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00')
247 self.assertEqual(i, Interval('28d')) 247 self.assertEqual(i, Interval('28d'))
248 i = Date('2003-03-03.00:00:00') - Date('2003-02-01.00:00:00')
249 self.assertEqual(i, Interval('30d'))
248 i = Date('2003-03-03.00:00:00') - Date('2002-02-01.00:00:00') 250 i = Date('2003-03-03.00:00:00') - Date('2002-02-01.00:00:00')
249 self.assertEqual(i, Interval('30d')) 251 self.assertEqual(i, Interval('395d'))
250 i = Date('2003-03-03.00:00:00') - Date('2002-04-01.00:00:00') 252 i = Date('2003-03-03.00:00:00') - Date('2003-04-01.00:00:00')
251 self.assertEqual(i, Interval('-29d')) 253 self.assertEqual(i, Interval('-29d'))
252 i = Date('2003-03-01.00:00:00') - Date('2002-02-01.00:00:00') 254 i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00')
253 self.assertEqual(i, Interval('1m')) 255 self.assertEqual(i, Interval('28d'))
254 # force the transition over a year boundary 256 # force the transition over a year boundary
255 i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00') 257 i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00')
256 self.assertEqual(i, Interval('365d')) 258 self.assertEqual(i, Interval('365d'))
257 259
258 def testIntervalAdd(self): 260 def testIntervalAdd(self):

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