From 7f4872bdfba6cc49dc132ec5f6108dd8fb8ac0b2 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Tue, 22 Mar 2011 04:48:59 -0400 Subject: [PATCH] Print 'danger warnings' based on deadline proximity. --- list.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/list.c b/list.c index 7c655bb..450961c 100644 --- a/list.c +++ b/list.c @@ -219,6 +219,34 @@ static void print_details(struct node *y, int indent, int summarise_kids, const } } if (!options->monochrome) printf("%s", NORMAL); + if (y->required_by > 0) { + time_t delta = y->required_by - time(NULL); + if (delta < 0) { + printf(options->monochrome ? + " [OVERDUE]" : + RED " [OVERDUE]" NORMAL); + } else if (delta < 24*60*60) { + printf(options->monochrome ? + " [due <24hr]" : + RED " [due <24hr]" NORMAL); + } else if (delta < 2*24*60*60) { + printf(options->monochrome ? + " [due <2d]" : + RED " [due <2d]" NORMAL); + } else if (delta < 3*24*60*60) { + printf(options->monochrome ? + " [due <3d]" : + YELLOW " [due <3d]" NORMAL); + } else if (delta < 4*24*60*60) { + printf(options->monochrome ? + " [due <4d]" : + YELLOW " [due <4d]" NORMAL); + } else if (delta < 5*24*60*60) { + printf(options->monochrome ? + " [due <5d]" : + GREEN " [due <5d]" NORMAL); + } + } printf("\n"); if (options->verbose) { -- 2.39.2