本文整理汇总了Python中luigi.parameter.DateIntervalParameter类的典型用法代码示例。如果您正苦于以下问题:Python DateIntervalParameter类的具体用法?Python DateIntervalParameter怎么用?Python DateIntervalParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateIntervalParameter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_week
def test_week(self):
# >>> datetime.date(2012, 1, 1).isocalendar()
# (2011, 52, 7)
# >>> datetime.date(2012, 12, 31).isocalendar()
# (2013, 1, 1)
di = DI().parse('2011-W52')
self.assertEqual(di.dates(), [datetime.date(2011, 12, 26) + datetime.timedelta(i) for i in range(7)])
self.assertEqual(di.next().dates(), [datetime.date(2012, 1, 2) + datetime.timedelta(i) for i in range(7)])
self.assertEqual(str(di), '2011-W52')
di = DI().parse('2013-W01')
self.assertEqual(di.dates(), [datetime.date(2012, 12, 31) + datetime.timedelta(i) for i in range(7)])
self.assertEqual(di.prev().dates(), [datetime.date(2012, 12, 24) + datetime.timedelta(i) for i in range(7)])
self.assertEqual(str(di), '2013-W01')
示例2: test_interval
def test_interval(self):
di = DI().parse('2012-01-01-2012-02-01')
self.assertEqual(di.dates(), [datetime.date(2012, 1, 1) + datetime.timedelta(i) for i in range(31)])
self.assertRaises(NotImplementedError, di.next)
self.assertRaises(NotImplementedError, di.prev)
self.assertEquals(di.to_string(), '2012-01-01-2012-02-01')
示例3: test_year
def test_year(self):
di = DI().parse('2012')
self.assertEqual(di.dates(), [datetime.date(2012, 1, 1) + datetime.timedelta(i) for i in range(366)])
self.assertEqual(di.next().dates(), [datetime.date(2013, 1, 1) + datetime.timedelta(i) for i in range(365)])
self.assertEqual(di.prev().dates(), [datetime.date(2011, 1, 1) + datetime.timedelta(i) for i in range(365)])
self.assertEqual(str(di), '2012')
示例4: test_month
def test_month(self):
di = DI().parse('2012-01')
self.assertEqual(di.dates(), [datetime.date(2012, 1, 1) + datetime.timedelta(i) for i in range(31)])
self.assertEqual(di.next().dates(), [datetime.date(2012, 2, 1) + datetime.timedelta(i) for i in range(29)])
self.assertEqual(di.prev().dates(), [datetime.date(2011, 12, 1) + datetime.timedelta(i) for i in range(31)])
self.assertEqual(str(di), '2012-01')
示例5: test_date
def test_date(self):
di = DI().parse('2012-01-01')
self.assertEqual(di.dates(), [datetime.date(2012, 1, 1)])
self.assertEqual(di.next().dates(), [datetime.date(2012, 1, 2)])
self.assertEqual(di.prev().dates(), [datetime.date(2011, 12, 31)])
self.assertEqual(str(di), '2012-01-01')
示例6: test_hours
def test_hours(self):
d = DI().parse('2015')
self.assertEquals(len(list(d.hours())), 24 * 365)