from .dates_day_of_week import day_of_week from .dates_days_between import days_between from .todo_due_status_types import DueStatus from .todo_item import Todo def due_status(todo: Todo, today: str) -> DueStatus: """One word for where a todo stands today; done wins, this-week is the rest of the ISO week.""" # Check the dates first, so a bad date is an error even on a done todo. if todo.due is not None: days_between(today, todo.due) else: day_of_week(today) if todo.done: return "done" if todo.due is None: return "none" days = days_between(today, todo.due) if days < 0: return "overdue" if days == 0: return "today" if days == 1: return "tomorrow" if days <= 7 - day_of_week(today): return "this-week" return "later"