From: richard Date: Sun, 2 Nov 2003 09:27:50 +0000 (+0000) Subject: woo, failing date arithmetic tests X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0eb14c01c4d6144e21892fcfc266bdfc57571283;p=roundup.git woo, failing date arithmetic tests git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1953 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/test/test_dates.py b/test/test_dates.py index b15abaf..bf594e8 100644 --- a/test/test_dates.py +++ b/test/test_dates.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: test_dates.py,v 1.25 2003-10-25 22:53:26 richard Exp $ +# $Id: test_dates.py,v 1.26 2003-11-02 09:27:50 richard Exp $ import unittest, time @@ -177,6 +177,71 @@ class DateTestCase(unittest.TestCase): then = now - Interval('2d') ae(str(Interval(str(then))), '- 2d') + def testIntervalAddMonthBoundary(self): + # force the transition over a month boundary + now = Date('2003-10-30.00:00:00') + then = now + Interval('2d') + self.assertEqual(str(then), '2003-11-01.00:00:00') + now = Date('2004-02-28.00:00:00') + then = now + Interval('1d') + self.assertEqual(str(then), '2004-02-29.00:00:00') + now = Date('2003-02-28.00:00:00') + then = now + Interval('1d') + self.assertEqual(str(then), '2003-03-01.00:00:00') + now = Date('2003-01-01.00:00:00') + then = now + Interval('59d') + self.assertEqual(str(then), '2003-03-01.00:00:00') + now = Date('2004-01-01.00:00:00') + then = now + Interval('59d') + self.assertEqual(str(then), '2004-02-29.00:00:00') + + def testIntervalSubtractMonthBoundary(self): + # force the transition over a month boundary + now = Date('2003-11-01.00:00:00') + then = now - Interval('2d') + self.assertEqual(str(then), '2003-10-30.00:00:00') + now = Date('2004-02-29.00:00:00') + then = now - Interval('1d') + self.assertEqual(str(then), '2004-02-28.00:00:00') + now = Date('2003-03-01.00:00:00') + then = now - Interval('1d') + self.assertEqual(str(then), '2003-02-08.00:00:00') + now = Date('2003-03-01.00:00:00') + then = now - Interval('59d') + self.assertEqual(str(then), '2003-01-01.00:00:00') + now = Date('2004-02-29.00:00:00') + then = now - Interval('59d') + self.assertEqual(str(then), '2004-01-01.00:00:00') + + def testIntervalAddYearBoundary(self): + # force the transition over a year boundary + now = Date('2003-12-30.00:00:00') + then = now + Interval('2d') + self.assertEqual(str(then), '2004-01-01.00:00:00') + now = Date('2003-01-01.00:00:00') + then = now + Interval('364d') + self.assertEqual(str(then), '2004-01-01.00:00:00') + now = Date('2004-01-01.00:00:00') + then = now + Interval('365d') + self.assertEqual(str(then), '2005-01-01.00:00:00') + + def testIntervalSubtractYearBoundary(self): + # force the transition over a year boundary + now = Date('2003-01-01.00:00:00') + then = now - Interval('2d') + self.assertEqual(str(then), '2002-12-30.00:00:00') + now = Date('2004-02-01.00:00:00') + then = now - Interval('365d') + self.assertEqual(str(then), '2003-02-01.00:00:00') + now = Date('2005-02-01.00:00:00') + then = now - Interval('365d') + self.assertEqual(str(then), '2004-02-02.00:00:00') + + def testDateSubtract(self): + # force the transition over a year boundary + i = Date('2003-01-01.00:00:00') - Date('2002-01-01.00:00:00') + self.assertEqual(str(i).strip(), '1y') + def testIntervalAdd(self): ae = self.assertEqual ae(str(Interval('1y') + Interval('1y')), '+ 2y')