util.py 文件源码

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

项目:tfatool 作者: TadLeonard 项目源码 文件源码
def _parse_date(date_els):
    if len(date_els) == 2:
        # assumed to be year-month or month-year
        a, b = date_els
        if _is_year(a):
            date_vals = a, b, 1  # 1st of month assumed
        elif _is_year(b):
            date_vals = b, a, 1  # 1st of month assumed
        else:
            date_vals = arrow.now().year, a, b  # assumed M/D of this year
    elif len(date_els) == 3:
        # assumed to be year-month-day or month-day-year
        a, b, c = date_els
        if _is_year(a):
            date_vals = a, b, c
        elif _is_year(c):
            date_vals = c, a, b
        else:
            raise ValueError("Date '{}' can't be understood".format(date_els))
    else:
        raise ValueError("Date '{}' can't be understood".format(date_els))
    return map(int, date_vals)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号