jobs.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pyriodic 作者: Ayehavgunne 项目源码 文件源码
def increment(self, when):
        """
        Takes a datetime object and if it is in the past compared to the present it will
        add the defined interval of time to it till it is in the future
        """
        while not self.is_in_future(when):
            n = now()
            if self.interval == 'daily':
                when = when + timedelta(days=1)
            elif self.interval == 'weekly':
                when = when + timedelta(days=7)
            elif self.interval == 'monthly':
                when = when + timedelta(days=monthrange(n.year, n.month)[1])
            elif self.interval == 'yearly':
                if isleap(n.year) and self.is_in_future(datetime(year=n.year, month=2, day=29)):
                    when = when + timedelta(days=366)
                else:
                    when = when + timedelta(days=365)
        return when
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号