Exemplo n.º 1
0
def _calendar_print(tasks: List[Tuple[Arrow, TaskDB]], date: Arrow) -> None:
    cols = [Column(f"{d}", justify="left") for d in weekdays]
    table = Table(*cols, title=date.format("MMMM"), box=box.MINIMAL, show_lines=True)
    today = (
        lambda d: "bold yellow"
        if d.isocalendar() == date.isocalendar()
        else "white"
        if d.month == date.month
        else "bright_black"
    )
    format = lambda date, db: Text("\n").join(
        [Text(f"{date.day}          ", style=today(date)), format_tdb(db, False, False)]
    )
    days = [format(date, db) for date, db in tasks]
    weeks = [days[i : i + 7] for i in range(0, len(days), 7)]
    for w in weeks:
        table.add_row(*w)
    print(table)
Exemplo n.º 2
0
def due_on(t: Task, date: arrow.Arrow) -> bool:
    task = arrow.get(t.due).isocalendar()
    date = date.isocalendar()
    return task == date