本文整理汇总了Python中luigi.parameter.DateIntervalParameter.dates方法的典型用法代码示例。如果您正苦于以下问题:Python DateIntervalParameter.dates方法的具体用法?Python DateIntervalParameter.dates怎么用?Python DateIntervalParameter.dates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luigi.parameter.DateIntervalParameter
的用法示例。
在下文中一共展示了DateIntervalParameter.dates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_week
# 需要导入模块: from luigi.parameter import DateIntervalParameter [as 别名]
# 或者: from luigi.parameter.DateIntervalParameter import dates [as 别名]
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
# 需要导入模块: from luigi.parameter import DateIntervalParameter [as 别名]
# 或者: from luigi.parameter.DateIntervalParameter import dates [as 别名]
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_month
# 需要导入模块: from luigi.parameter import DateIntervalParameter [as 别名]
# 或者: from luigi.parameter.DateIntervalParameter import dates [as 别名]
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')
示例4: test_year
# 需要导入模块: from luigi.parameter import DateIntervalParameter [as 别名]
# 或者: from luigi.parameter.DateIntervalParameter import dates [as 别名]
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')
示例5: test_date
# 需要导入模块: from luigi.parameter import DateIntervalParameter [as 别名]
# 或者: from luigi.parameter.DateIntervalParameter import dates [as 别名]
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')