X-Git-Url: http://git.joshuawise.com/tdl.git/blobdiff_plain/9d5bee3ba0b2ddba7cf15637923de3b4d1f5a19d..aee3c241b7eaed3ef659570c7a4eb9654c1e3702:/list.c diff --git a/list.c b/list.c index 7c655bb..d9bfed5 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) { @@ -240,11 +268,11 @@ static void print_details(struct node *y, int indent, int summarise_kids, const /* 1 if x has lower priority than y. */ static int node_lessthan(struct node *x, struct node *y)/*{{{*/ { - if (x->priority < y->priority) - return 1; if (x->priority > y->priority) + return 1; + if (x->priority < y->priority) return 0; - if (x->required_by == 0 && y->required_by == 0) + if (x->required_by == y->required_by) return (x->idx > y->idx); if (y->required_by == 0) return 1;