From f7f674f7a000adfe595924b47dbfc873b303816a Mon Sep 17 00:00:00 2001 From: augustin64 Date: Wed, 12 Jul 2023 22:21:14 +0200 Subject: [PATCH] Highlight expired tasks --- src/db.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index 7ccdb1f..b89711a 100644 --- a/src/db.c +++ b/src/db.c @@ -201,6 +201,7 @@ int list_tasks(bool show_completed) { return 1; } + time_t now = time(0); while (sqlite3_step(stmt) == SQLITE_ROW) { task_t t; @@ -212,10 +213,16 @@ int list_tasks(bool show_completed) { if (t.done) { 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 { - 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); } }