Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
import { dayOfWeek } from "./dates_day_of_week.ts"; ← from dates.day-of-week ^1.0.0 · built alongside by fune
import { daysBetween } from "./dates_days_between.ts"; ← from dates.days-between ^1.0.0 · built alongside by fune
import { type DueStatus } from "./todo_due_status_types.ts";
import { type Todo } from "./todo_item.ts"; ← from todo.item ^1.0.0 · built alongside by fune
/**
* One word for where a todo stands today. A done todo is `done` whatever its
* date, so nothing finished ever shows as overdue. `this-week` is the rest of
* the current ISO week (Monday to Sunday) after tomorrow, so on Saturday and
* Sunday there is no `this-week`: Monday is next week.
*/
export function dueStatus(todo: Todo, today: string): DueStatus {
if (todo.due !== null && todo.due !== undefined) daysBetween(today, todo.due);
else dayOfWeek(today);
if (todo.done) return "done";
if (todo.due === null || todo.due === undefined) return "none";
const days = daysBetween(today, todo.due);
if (days < 0) return "overdue";
if (days === 0) return "today";
if (days === 1) return "tomorrow";
if (days <= 7 - dayOfWeek(today)) return "this-week";
return "later";
}