Highlight expired tasks

This commit is contained in:
augustin64 2023-07-12 22:21:14 +02:00
parent 722c88a1b2
commit f7f674f7a0

View File

@ -201,6 +201,7 @@ int list_tasks(bool show_completed) {
return 1; return 1;
} }
time_t now = time(0);
while (sqlite3_step(stmt) == SQLITE_ROW) { while (sqlite3_step(stmt) == SQLITE_ROW) {
task_t t; task_t t;
@ -212,10 +213,16 @@ int list_tasks(bool show_completed) {
if (t.done) { if (t.done) {
if (show_completed) { if (show_completed) {
printf(BOLD GREEN "[%d]" RESET " %s\n", t.id, t.text); printf(BOLD GREEN); // Task completed
} }
} else if (difftime(now, t.due_to) <= 0 || t.due_to == 0) {
printf(BOLD YELLOW); // Task not completed but that is fine
} else { } else {
printf(BOLD YELLOW "[%d]" RESET " %s\n", t.id, t.text); printf(BOLD RED); // Task not completed but should be !
}
if (!t.done || show_completed) {
printf("[%d]" RESET " %s\n", t.id, t.text);
} }
} }