slackbot.py 文件源码

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

项目:slackbot 作者: Parsely 项目源码 文件源码
def from_str(cls, time):
        ''' takes a string like 1h, 2m, and returns a time_period object '''
        # let's compute some sane things from these
        time_period = cls()
        if time == 'today':
            time_period.hours = int(dt.now(tzlocal.get_localzone()).hour)
            return time_period

        if time.lower().endswith(('h', 'm')) and time[:-1].isdigit():
            qualifier, time = time[-1].lower(), int(time[:-1])
            if qualifier == 'h':
                time_period.time_str = 'Hour' if time == 1 else 'Hours'
                time_period.hours = time
            if qualifier == 'm':
                time_period.time_str = 'Minutes'
                time_period.minutes = time if time >= 5 else 5
            return time_period
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号