当前位置: 首页>>代码示例>>Python>>正文


Python CronParser.get_next方法代码示例

本文整理汇总了Python中gluon.scheduler.CronParser.get_next方法的典型用法代码示例。如果您正苦于以下问题:Python CronParser.get_next方法的具体用法?Python CronParser.get_next怎么用?Python CronParser.get_next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gluon.scheduler.CronParser的用法示例。


在下文中一共展示了CronParser.get_next方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMonth

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testMonth(self):
        base = datetime.datetime(2010, 1, 25)
        itr = CronParser('0 0 1 * *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.month, 2)
        self.assertEqual(n1.day, 1)
        n2 = itr.get_next()
        self.assertEqual(n2.month, 3)
        self.assertEqual(n2.day, 1)
        for i in range(8):
            itr.get_next()
        n3 = itr.get_next()
        self.assertEqual(n3.month, 12)
        self.assertEqual(n3.year, 2010)
        n4 = itr.get_next()
        self.assertEqual(n4.month, 1)
        self.assertEqual(n4.year, 2011)

        base = datetime.datetime(2010, 1, 25)
        itr = CronParser('0 0 1 */4 *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.month, 5)
        self.assertEqual(n1.day, 1)

        base = datetime.datetime(2010, 1, 25)
        itr = CronParser('0 0 1 1-3 *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.month, 2)
        self.assertEqual(n1.day, 1)
        n2 = itr.get_next()
        self.assertEqual(n2.month, 3)
        self.assertEqual(n2.day, 1)
        n3 = itr.get_next()
        self.assertEqual(n3.month, 1)
        self.assertEqual(n3.day, 1)
开发者ID:web2py,项目名称:web2py,代码行数:37,代码来源:test_scheduler.py

示例2: testWeekDay

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testWeekDay(self):
        base = datetime.datetime(2010, 2, 25)
        itr = CronParser('0 0 * * sat', base)
        n1 = itr.get_next()
        self.assertEqual(n1.isoweekday(), 6)
        self.assertEqual(n1.day, 27)
        n2 = itr.get_next()
        self.assertEqual(n2.isoweekday(), 6)
        self.assertEqual(n2.day, 6)
        self.assertEqual(n2.month, 3)

        base = datetime.datetime(2010, 1, 25)
        itr = CronParser('0 0 1 * wed', base)
        n1 = itr.get_next()
        self.assertEqual(n1.month, 1)
        self.assertEqual(n1.day, 27)
        self.assertEqual(n1.year, 2010)
        n2 = itr.get_next()
        self.assertEqual(n2.month, 2)
        self.assertEqual(n2.day, 1)
        self.assertEqual(n2.year, 2010)
        n3 = itr.get_next()
        self.assertEqual(n3.month, 2)
        self.assertEqual(n3.day, 3)
        self.assertEqual(n3.year, 2010)
开发者ID:web2py,项目名称:web2py,代码行数:27,代码来源:test_scheduler.py

示例3: testHour

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
 def testHour(self):
     base = datetime.datetime(2010, 1, 24, 12, 2)
     itr = CronParser('0 */3 * * *', base)
     n1 = itr.get_next()
     self.assertEqual(n1.hour, 15)
     self.assertEqual(n1.minute, 0)
     for i in range(2):
         itr.get_next()
     n2 = itr.get_next()
     self.assertEqual(n2.hour, 0)
     self.assertEqual(n2.day, 25)
开发者ID:web2py,项目名称:web2py,代码行数:13,代码来源:test_scheduler.py

示例4: test_rangeGenerator

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
 def test_rangeGenerator(self):
     base = datetime.datetime(2013, 3, 4, 0, 0)
     itr = CronParser('1-9/2 0 1 * *', base)
     n1 = itr.get_next()
     n2 = itr.get_next()
     n3 = itr.get_next()
     n4 = itr.get_next()
     n5 = itr.get_next()
     self.assertEqual(n1.minute, 1)
     self.assertEqual(n2.minute, 3)
     self.assertEqual(n3.minute, 5)
     self.assertEqual(n4.minute, 7)
     self.assertEqual(n5.minute, 9)
开发者ID:web2py,项目名称:web2py,代码行数:15,代码来源:test_scheduler.py

示例5: testBug3

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testBug3(self):
        base = datetime.datetime(2013, 3, 1, 12, 17, 34, 257877)
        c = CronParser('00 03 16,30 * *', base)

        n1 = c.get_next()
        self.assertEqual(n1.month, 3)
        self.assertEqual(n1.day, 16)

        n2 = c.get_next()
        self.assertEqual(n2.month, 3)
        self.assertEqual(n2.day, 30)

        n3 = c.get_next()
        self.assertEqual(n3.month, 4)
        self.assertEqual(n3.day, 16)
开发者ID:web2py,项目名称:web2py,代码行数:17,代码来源:test_scheduler.py

示例6: testDay

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testDay(self):
        base = datetime.datetime(2010, 2, 24, 12, 9)
        itr = CronParser('0 0 */3 * *', base)
        n1 = itr.get_next()
        # 1 4 7 10 13 16 19 22 25 28
        self.assertEqual(n1.day, 25)
        n2 = itr.get_next()
        self.assertEqual(n2.day, 28)
        n3 = itr.get_next()
        self.assertEqual(n3.day, 1)
        self.assertEqual(n3.month, 3)

        # test leap year
        base = datetime.datetime(1996, 2, 27)
        itr = CronParser('0 0 * * *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 28)
        self.assertEqual(n1.month, 2)
        n2 = itr.get_next()
        self.assertEqual(n2.day, 29)
        self.assertEqual(n2.month, 2)

        base2 = datetime.datetime(2000, 2, 27)
        itr2 = CronParser('0 0 * * *', base2)
        n3 = itr2.get_next()
        self.assertEqual(n3.day, 28)
        self.assertEqual(n3.month, 2)
        n4 = itr2.get_next()
        self.assertEqual(n4.day, 29)
        self.assertEqual(n4.month, 2)
开发者ID:web2py,项目名称:web2py,代码行数:32,代码来源:test_scheduler.py

示例7: testISOWeekday

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
 def testISOWeekday(self):
     base = datetime.datetime(2010, 2, 25)
     itr = CronParser('0 0 * * 7', base)
     n1 = itr.get_next()
     self.assertEqual(n1.isoweekday(), 7)
     self.assertEqual(n1.day, 28)
     n2 = itr.get_next()
     self.assertEqual(n2.isoweekday(), 7)
     self.assertEqual(n2.day, 7)
     self.assertEqual(n2.month, 3)
     base = datetime.datetime(2010, 2, 22)
     itr = CronParser('0 0 * * */2', base)
     n1 = itr.get_next()
     self.assertEqual(n1.isoweekday(), 2)
     self.assertEqual(n1.day, 23)
     n2 = itr.get_next()
     self.assertEqual(n2.isoweekday(), 4)
     self.assertEqual(n2.day, 25)
开发者ID:web2py,项目名称:web2py,代码行数:20,代码来源:test_scheduler.py

示例8: testSundayToThursdayWithAlphaConversion

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
 def testSundayToThursdayWithAlphaConversion(self):
     base = datetime.datetime(2010, 8, 25, 15, 56)
     itr = CronParser("30 22 * * sun-thu", base)
     n1 = itr.get_next()
     self.assertEqual(base.year, n1.year)
     self.assertEqual(base.month, n1.month)
     self.assertEqual(base.day, n1.day)
     self.assertEqual(22, n1.hour)
     self.assertEqual(30, n1.minute)
开发者ID:web2py,项目名称:web2py,代码行数:11,代码来源:test_scheduler.py

示例9: testBug2

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testBug2(self):

        base = datetime.datetime(2012, 1, 1, 0, 0)
        itr = CronParser('0 * * 3 *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.month, 3)
        self.assertEqual(n1.day, base.day)
        self.assertEqual(n1.hour, base.hour)
        self.assertEqual(n1.minute, base.minute)

        n2 = itr.get_next()
        self.assertEqual(n2.year, base.year)
        self.assertEqual(n2.month, 3)
        self.assertEqual(n2.day, base.day)
        self.assertEqual(n2.hour, base.hour + 1)
        self.assertEqual(n2.minute, base.minute)

        n3 = itr.get_next()
        self.assertEqual(n3.year, base.year)
        self.assertEqual(n3.month, 3)
        self.assertEqual(n3.day, base.day)
        self.assertEqual(n3.hour, base.hour + 2)
        self.assertEqual(n3.minute, base.minute)
开发者ID:web2py,项目名称:web2py,代码行数:26,代码来源:test_scheduler.py

示例10: testLastDayOfMonth

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testLastDayOfMonth(self):
        base = datetime.datetime(2015, 9, 4)
        itr = CronParser('0 0 L * *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.month, 9)
        self.assertEqual(n1.day, 30)
        n2 = itr.get_next()
        self.assertEqual(n2.month, 10)
        self.assertEqual(n2.day, 31)
        n3 = itr.get_next()
        self.assertEqual(n3.month, 11)
        self.assertEqual(n3.day, 30)
        n4 = itr.get_next()
        self.assertEqual(n4.month, 12)
        self.assertEqual(n4.day, 31)

        base = datetime.datetime(1996, 2, 27)
        itr = CronParser('0 0 L * *', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 29)
        self.assertEqual(n1.month, 2)
        n2 = itr.get_next()
        self.assertEqual(n2.day, 31)
        self.assertEqual(n2.month, 3)
开发者ID:web2py,项目名称:web2py,代码行数:26,代码来源:test_scheduler.py

示例11: testMinute

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testMinute(self):
        # minute asterisk
        base = datetime.datetime(2010, 1, 23, 12, 18)
        itr = CronParser('*/1 * * * *', base)
        n1 = itr.get_next()    # 19
        self.assertEqual(base.year, n1.year)
        self.assertEqual(base.month, n1.month)
        self.assertEqual(base.day, n1.day)
        self.assertEqual(base.hour, n1.hour)
        self.assertEqual(base.minute, n1.minute - 1)
        for i in range(39):  # ~ 58
            itr.get_next()
        n2 = itr.get_next()
        self.assertEqual(n2.minute, 59)
        n3 = itr.get_next()
        self.assertEqual(n3.minute, 0)
        self.assertEqual(n3.hour, 13)

        itr = CronParser('*/5 * * * *', base)
        n4 = itr.get_next()
        self.assertEqual(n4.minute, 20)
        for i in range(6):
            itr.get_next()
        n5 = itr.get_next()
        self.assertEqual(n5.minute, 55)
        n6 = itr.get_next()
        self.assertEqual(n6.minute, 0)
        self.assertEqual(n6.hour, 13)

        base = datetime.datetime(2010, 1, 23, 12, 18)
        itr = CronParser('4/34 * * * *', base)
        n7 = itr.get_next()
        self.assertEqual(n7.minute, 38)
        self.assertEqual(n7.hour, 12)
        n8 = itr.get_next()
        self.assertEqual(n8.minute, 4)
        self.assertEqual(n8.hour, 13)
开发者ID:web2py,项目名称:web2py,代码行数:39,代码来源:test_scheduler.py

示例12: testSpecialExpr

# 需要导入模块: from gluon.scheduler import CronParser [as 别名]
# 或者: from gluon.scheduler.CronParser import get_next [as 别名]
    def testSpecialExpr(self):
        base = datetime.datetime(2000, 1, 1)
        itr = CronParser('@yearly', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 1)
        self.assertEqual(n1.month, 1)
        self.assertEqual(n1.year, base.year + 1)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)

        itr = CronParser('@annually', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 1)
        self.assertEqual(n1.month, 1)
        self.assertEqual(n1.year, base.year + 1)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)

        itr = CronParser('@monthly', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 1)
        self.assertEqual(n1.month, base.month + 1)
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)

        itr = CronParser('@weekly', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 2)
        self.assertEqual(n1.month, base.month)
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)
        n2 = itr.get_next()
        self.assertEqual(n2.day, 9)
        self.assertEqual(n2.month, base.month)
        self.assertEqual(n2.year, base.year)
        self.assertEqual(n2.hour, 0)
        self.assertEqual(n2.minute, 0)
        n3 = itr.get_next()
        self.assertEqual(n3.day, 16)
        self.assertEqual(n3.month, base.month)
        self.assertEqual(n3.year, base.year)
        self.assertEqual(n3.hour, 0)
        self.assertEqual(n3.minute, 0)

        itr = CronParser('@daily', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 2)
        self.assertEqual(n1.month, base.month)
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)

        itr = CronParser('@midnight', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 2)
        self.assertEqual(n1.month, base.month)
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.hour, 0)
        self.assertEqual(n1.minute, 0)

        itr = CronParser('@hourly', base)
        n1 = itr.get_next()
        self.assertEqual(n1.day, 1)
        self.assertEqual(n1.month, base.month)
        self.assertEqual(n1.year, base.year)
        self.assertEqual(n1.hour, 1)
        self.assertEqual(n1.minute, 0)
开发者ID:web2py,项目名称:web2py,代码行数:71,代码来源:test_scheduler.py


注:本文中的gluon.scheduler.CronParser.get_next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。