utils.py 文件源码

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

项目:lagendacommun 作者: ecreall 项目源码 文件源码
def get_month_range(start_date=None, next_month=False):
    if start_date is None:
        start_date = datetime.date.today()

    month = start_date.month
    year = start_date.year
    if next_month:
        month = 1 if start_date.month == 12 else start_date.month + 1
        if month == 1:
            year += 1

    start_date = start_date.replace(day=1, month=month, year=year)
    _, days_in_month = calendar.monthrange(year, month)
    end_date = start_date + datetime.timedelta(days=days_in_month-1)
    return (start_date, end_date)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号