2026-05-07 16:31:56 +08:00

22 lines
599 B
Python

from __future__ import annotations
import json
from datetime import date
from pathlib import Path
def is_workday(selected_date: date, calendar_path: Path) -> bool:
if not calendar_path.exists():
return selected_date.weekday() < 5
calendar = json.loads(calendar_path.read_text(encoding="utf-8"))
day = selected_date.isoformat()
holidays = set(calendar.get("holidays", []))
makeup_workdays = set(calendar.get("makeup_workdays", []))
if day in makeup_workdays:
return True
if day in holidays:
return False
return selected_date.weekday() < 5