Exemplo n.º 1
0
def is_working_day(target: datetime.date) -> bool:
    """指定日が休日か判定する"""
    if target.weekday() >= 5:
        # 土曜 or 日曜
        return False
    if jpholiday.is_holiday(target):
        # 祝日
        return False
    return True
Exemplo n.º 2
0
    def get_previous_by_day(index: int, start_date: datetime.date = None):
        """

        :param index: Monday 0 ~ Sunday 6
        :param start_date:
        :return:
        """
        if start_date is None:
            start_date = datetime.today().date()
        day_num = start_date.weekday()
        days_ago = (7 + day_num - index) % 7
        days_ago = 7 if days_ago == 0 else days_ago
        return start_date - timedelta(days=days_ago)