comparison test/test_dates.py @ 1886:e3cff1bb1b86

more tests for date difference. Completely broken code right now.
author Anthony Baxter <anthonybaxter@users.sourceforge.net>
date Mon, 03 Nov 2003 10:33:23 +0000
parents deba54ed724f
children 41ad8b781232
comparison
equal deleted inserted replaced
1885:deba54ed724f 1886:e3cff1bb1b86
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.27 2003-11-03 10:23:06 anthonybaxter Exp $ 18 # $Id: test_dates.py,v 1.28 2003-11-03 10:33:23 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
236 now = Date('2005-02-01.00:00:00') 236 now = Date('2005-02-01.00:00:00')
237 then = now - Interval('365d') 237 then = now - Interval('365d')
238 self.assertEqual(str(then), '2004-02-02.00:00:00') 238 self.assertEqual(str(then), '2004-02-02.00:00:00')
239 239
240 def testDateSubtract(self): 240 def testDateSubtract(self):
241 # These are thoroughly broken right now.
242 i = Date('2003-03-15.00:00:00') - Date('2003-03-10.00:00:00')
243 self.assertEqual(i, Interval('5d'))
244 i = Date('2003-02-01.00:00:00') - Date('2003-03-01.00:00:00')
245 self.assertEqual(i, Interval('-28d'))
246 i = Date('2003-03-01.00:00:00') - Date('2003-02-01.00:00:00')
247 self.assertEqual(i, Interval('28d'))
248 i = Date('2003-03-03.00:00:00') - Date('2002-02-01.00:00:00')
249 self.assertEqual(i, Interval('30d'))
250 i = Date('2003-03-03.00:00:00') - Date('2002-04-01.00:00:00')
251 self.assertEqual(i, Interval('-29d'))
252 i = Date('2003-03-01.00:00:00') - Date('2002-02-01.00:00:00')
253 self.assertEqual(i, Interval('1m'))
241 # force the transition over a year boundary 254 # force the transition over a year boundary
242 i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00') 255 i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00')
243 self.assertEqual(str(i).strip(), '1y') 256 self.assertEqual(i, Interval('365d'))
244 257
245 def testIntervalAdd(self): 258 def testIntervalAdd(self):
246 ae = self.assertEqual 259 ae = self.assertEqual
247 ae(str(Interval('1y') + Interval('1y')), '+ 2y') 260 ae(str(Interval('1y') + Interval('1y')), '+ 2y')
248 ae(str(Interval('1y') + Interval('1m')), '+ 1y 1m') 261 ae(str(Interval('1y') + Interval('1m')), '+ 1y 1m')

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