# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/dt/common.ipynb.

# %% auto 0
__all__ = ['get_last_day_of_month', 'get_dates_in_year', 'get_dates_in_month']

# %% ../../nbs/dt/common.ipynb 1
import calendar
import datetime
from typing import List


def get_last_day_of_month(year: int, month: int) -> int:
    """Get last day of month"""
    # https://stackoverflow.com/a/43663/1617883
    return calendar.monthrange(year, month)[1]


def get_dates_in_year(year: int) -> List[datetime.date]:
    """Returns a list with datetimes for each day a year"""
    d1 = datetime.date(year, 1, 1)
    d2 = datetime.date(year, 12, get_last_day_of_month(year, 12))
    delta = d2 - d1
    return [d1 + datetime.timedelta(i) for i in range(delta.days + 1)]


def get_dates_in_month(year: int, month: int) -> List[datetime.datetime]:
    """Returns a list with datetimes for each day a year"""
    d1 = datetime.date(year, month, 1)
    d2 = datetime.date(year, month, get_last_day_of_month(year, month))
    delta = d2 - d1
    return [d1 + datetime.timedelta(i) for i in range(delta.days + 1)]
