bday.py 文件源码

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

项目:Abb1t 作者: k-freeman 项目源码 文件源码
def seconds_until(until=9):
    """ Counts the seconds until it is a certain hour again.

    Keyword Arguments:
        until (int): the hour we want to count to (default: {9})

    Returns:
        (float): how many seconds until the specified time.
    """
    now = time.localtime()
    now_sec = time.mktime(now)

    if now.tm_hour >= until:
        delta = (until * 60 * 60) \
            + (60 * 60 * (24 - now.tm_hour)) \
            - (60 * now.tm_min) \
            - (now.tm_sec)
    else:
        delta = (until * 60 * 60) \
            - (60 * 60 * now.tm_hour) \
            - (60 * now.tm_min) \
            - (now.tm_sec)

    then = time.localtime(now_sec + delta)
    return time.mktime(then) - time.time()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号