Mercurial > p > roundup > code
comparison test/test_dates.py @ 641:cfa460943d4d
Oops, there's 24 hours in a day...
...and subtraction of intervals now works properly.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 21 Feb 2002 23:34:52 +0000 |
| parents | 7dd13fd5d8ea |
| children | 68cef2bb929d |
comparison
equal
deleted
inserted
replaced
| 640:7dd13fd5d8ea | 641:cfa460943d4d |
|---|---|
| 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.10 2002-02-21 23:11:45 richard Exp $ | 18 # $Id: test_dates.py,v 1.11 2002-02-21 23:34:52 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 |
| 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 | 73 |
| 74 # now check calculations | 74 # now check calculations |
| 75 date = Date('2000-01-01') + Interval('- 2y 2m') | 75 date = Date('2000-01-01') + Interval('- 2y 2m') |
| 76 ae(str(date), '1997-11-01.00:00:00') | 76 ae(str(date), '1997-11-01.00:00:00') |
| 77 date = Date('2000-01-01') + Interval('+ 2m') | 77 date = Date('2000-01-01') + Interval('2m') |
| 78 ae(str(date), '2000-03-01.00:00:00') | 78 ae(str(date), '2000-03-01.00:00:00') |
| 79 | 79 |
| 80 date = Date('2000-01-01') + Interval('60d') | 80 date = Date('2000-01-01') + Interval('60d') |
| 81 ae(str(date), '2000-03-01.00:00:00') | 81 ae(str(date), '2000-03-01.00:00:00') |
| 82 date = Date('2001-01-01') + Interval('60d') | 82 date = Date('2001-01-01') + Interval('60d') |
| 83 ae(str(date), '2001-03-02.00:00:00') | 83 ae(str(date), '2001-03-02.00:00:00') |
| 84 | 84 |
| 85 # time additions | |
| 85 date = Date('2000-02-28.23:59:59') + Interval('00:00:01') | 86 date = Date('2000-02-28.23:59:59') + Interval('00:00:01') |
| 86 ae(str(date), '2000-02-29.00:00:00') | 87 ae(str(date), '2000-02-29.00:00:00') |
| 87 date = Date('2001-02-28.23:59:59') + Interval('00:00:01') | 88 date = Date('2001-02-28.23:59:59') + Interval('00:00:01') |
| 88 ae(str(date), '2001-03-01.00:00:00') | 89 ae(str(date), '2001-03-01.00:00:00') |
| 89 | 90 |
| 100 date = Date('2000-02-28.22:58:59') + Interval('00:00:3661') | 101 date = Date('2000-02-28.22:58:59') + Interval('00:00:3661') |
| 101 ae(str(date), '2000-02-29.00:00:00') | 102 ae(str(date), '2000-02-29.00:00:00') |
| 102 date = Date('2001-02-28.22:58:59') + Interval('00:00:3661') | 103 date = Date('2001-02-28.22:58:59') + Interval('00:00:3661') |
| 103 ae(str(date), '2001-03-01.00:00:00') | 104 ae(str(date), '2001-03-01.00:00:00') |
| 104 | 105 |
| 106 # now subtractions | |
| 107 date = Date('2000-01-01') - Interval('- 2y 2m') | |
| 108 ae(str(date), '2002-03-01.00:00:00') | |
| 109 date = Date('2000-01-01') - Interval('2m') | |
| 110 ae(str(date), '1999-11-01.00:00:00') | |
| 111 | |
| 112 date = Date('2000-03-01') - Interval('60d') | |
| 113 ae(str(date), '2000-01-01.00:00:00') | |
| 114 date = Date('2001-03-02') - Interval('60d') | |
| 115 ae(str(date), '2001-01-01.00:00:00') | |
| 116 | |
| 117 date = Date('2000-02-29.00:00:00') - Interval('00:00:01') | |
| 118 ae(str(date), '2000-02-28.23:59:59') | |
| 119 date = Date('2001-03-01.00:00:00') - Interval('00:00:01') | |
| 120 ae(str(date), '2001-02-28.23:59:59') | |
| 121 | |
| 122 date = Date('2000-02-29.00:00:00') - Interval('00:01:01') | |
| 123 ae(str(date), '2000-02-28.23:58:59') | |
| 124 date = Date('2001-03-01.00:00:00') - Interval('00:01:01') | |
| 125 ae(str(date), '2001-02-28.23:58:59') | |
| 126 | |
| 127 date = Date('2000-02-29.00:00:00') - Interval('01:01:01') | |
| 128 ae(str(date), '2000-02-28.22:58:59') | |
| 129 date = Date('2001-03-01.00:00:00') - Interval('01:01:01') | |
| 130 ae(str(date), '2001-02-28.22:58:59') | |
| 131 | |
| 132 date = Date('2000-02-29.00:00:00') - Interval('00:00:3661') | |
| 133 ae(str(date), '2000-02-28.22:58:59') | |
| 134 date = Date('2001-03-01.00:00:00') - Interval('00:00:3661') | |
| 135 ae(str(date), '2001-02-28.22:58:59') | |
| 136 | |
| 105 def testInterval(self): | 137 def testInterval(self): |
| 106 ae = self.assertEqual | 138 ae = self.assertEqual |
| 107 ae(str(Interval('3y')), '+ 3y') | 139 ae(str(Interval('3y')), '+ 3y') |
| 108 ae(str(Interval('2 y 1 m')), '+ 2y 1m') | 140 ae(str(Interval('2 y 1 m')), '+ 2y 1m') |
| 109 ae(str(Interval('1m 25d')), '+ 1m 25d') | 141 ae(str(Interval('1m 25d')), '+ 1m 25d') |
| 116 return unittest.makeSuite(DateTestCase, 'test') | 148 return unittest.makeSuite(DateTestCase, 'test') |
| 117 | 149 |
| 118 | 150 |
| 119 # | 151 # |
| 120 # $Log: not supported by cvs2svn $ | 152 # $Log: not supported by cvs2svn $ |
| 153 # Revision 1.10 2002/02/21 23:11:45 richard | |
| 154 # . fixed some problems in date calculations (calendar.py doesn't handle over- | |
| 155 # and under-flow). Also, hour/minute/second intervals may now be more than | |
| 156 # 99 each. | |
| 157 # | |
| 121 # Revision 1.9 2002/02/21 06:57:39 richard | 158 # Revision 1.9 2002/02/21 06:57:39 richard |
| 122 # . Added popup help for classes using the classhelp html template function. | 159 # . Added popup help for classes using the classhelp html template function. |
| 123 # - add <display call="classhelp('priority', 'id,name,description')"> | 160 # - add <display call="classhelp('priority', 'id,name,description')"> |
| 124 # to an item page, and it generates a link to a popup window which displays | 161 # 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 | 162 # the id, name and description for the priority class. The description |
