Mercurial > p > roundup > code
comparison test/test_dates.py @ 1599:cc96bf971b33
extended date syntax to make range searches even more useful
| author | Andrey Lebedev <kedder@users.sourceforge.net> |
|---|---|
| date | Tue, 22 Apr 2003 20:53:55 +0000 |
| parents | 4d55f90d4af1 |
| children | f63aa57386b0 b3f63a0615db |
comparison
equal
deleted
inserted
replaced
| 1598:b3263567b8c6 | 1599:cc96bf971b33 |
|---|---|
| 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.23 2003-04-21 14:29:40 kedder Exp $ | 18 # $Id: test_dates.py,v 1.24 2003-04-22 20:53:54 kedder 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 |
| 54 ae(str(date), '%s-11-07.09:32:43'%y) | 54 ae(str(date), '%s-11-07.09:32:43'%y) |
| 55 date = Date("14:25") | 55 date = Date("14:25") |
| 56 ae(str(date), '%s-%02d-%02d.14:25:00'%(y, m, d)) | 56 ae(str(date), '%s-%02d-%02d.14:25:00'%(y, m, d)) |
| 57 date = Date("8:47:11") | 57 date = Date("8:47:11") |
| 58 ae(str(date), '%s-%02d-%02d.08:47:11'%(y, m, d)) | 58 ae(str(date), '%s-%02d-%02d.08:47:11'%(y, m, d)) |
| 59 ae(str(Date('2003')), '2003-01-01.00:00:00') | |
| 60 ae(str(Date('2004-06')), '2004-06-01.00:00:00') | |
| 59 | 61 |
| 60 def testDateError(self): | 62 def testDateError(self): |
| 61 self.assertRaises(ValueError, Date, "12") | 63 self.assertRaises(ValueError, Date, "12") |
| 62 | 64 |
| 63 def testOffset(self): | 65 def testOffset(self): |
| 247 | 249 |
| 248 def testGranularity(self): | 250 def testGranularity(self): |
| 249 ae = self.assertEqual | 251 ae = self.assertEqual |
| 250 ae(str(Date('2003-2-12', add_granularity=1)), '2003-02-12.23:59:59') | 252 ae(str(Date('2003-2-12', add_granularity=1)), '2003-02-12.23:59:59') |
| 251 ae(str(Date('2003-1-1.23:00', add_granularity=1)), '2003-01-01.23:00:59') | 253 ae(str(Date('2003-1-1.23:00', add_granularity=1)), '2003-01-01.23:00:59') |
| 254 ae(str(Date('2003', add_granularity=1)), '2003-12-31.23:59:59') | |
| 255 ae(str(Date('2003-5', add_granularity=1)), '2003-05-31.23:59:59') | |
| 252 ae(str(Interval('+1w', add_granularity=1)), '+ 14d') | 256 ae(str(Interval('+1w', add_granularity=1)), '+ 14d') |
| 253 ae(str(Interval('-2m 3w', add_granularity=1)), '- 2m 14d') | 257 ae(str(Interval('-2m 3w', add_granularity=1)), '- 2m 14d') |
| 254 | 258 |
| 255 def suite(): | 259 def suite(): |
| 256 return unittest.makeSuite(DateTestCase, 'test') | 260 return unittest.makeSuite(DateTestCase, 'test') |
