diff options
-rw-r--r-- | date.py | 2 | ||||
-rw-r--r-- | test/unittest_date.py | 7 |
2 files changed, 8 insertions, 1 deletions
@@ -188,8 +188,8 @@ def date_range(begin, end, incday=None, incmonth=None): end = todate(end) if incmonth: while begin < end: - begin = next_month(begin, incmonth) yield begin + begin = next_month(begin, incmonth) else: incr = get_step(begin, incday or 1) while begin < end: diff --git a/test/unittest_date.py b/test/unittest_date.py index 0aa1de8..ba1522c 100644 --- a/test/unittest_date.py +++ b/test/unittest_date.py @@ -138,6 +138,13 @@ class DateTC(TestCase): date = ticks2datetime(ticks) self.assertEqual(ustrftime(date, '%Y-%m-%d'), u'1899-12-31') + def test_month(self): + """enumerate months""" + r = list(date_range(self.datecls(2006, 5, 6), self.datecls(2006, 8, 27), + incmonth=True)) + expected = [self.datecls(2006, 5, 6), self.datecls(2006, 6, 1), self.datecls(2006, 7, 1), self.datecls(2006, 8, 1)] + self.assertListEqual(expected, r) + class MxDateTC(DateTC): datecls = mxDate |