diff --git a/ChangeLog b/ChangeLog index 0449111df..f68726764 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,7 @@ - Removed unused 'dom' and 'shell.prompt' configuration settings. - Numerous performance improvements. Taskwarrior 2.5.1 is between X% and Y% faster than 2.5.0 when running various commands. +- New formatting specifier 'relative' for columns of Date type was introduced. ------ current release --------------------------- diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index 4e11f6d10..1514bb6e7 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -45,6 +45,7 @@ ColumnTypeDate::ColumnTypeDate () "epoch", "iso", "age", + "relative", "remaining", "countdown"}; @@ -55,6 +56,7 @@ ColumnTypeDate::ColumnTypeDate () now.toEpochString (), now.toISO (), ISO8601p (ISO8601d () - now).formatVague (), + "-" + ISO8601p (ISO8601d () - now).formatVague (), "", ISO8601p (ISO8601d () - now).format ()}; } @@ -115,6 +117,14 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m else minimum = maximum = ISO8601p (date - now).formatVague ().length () + 1; } + else if (_style == "relative") + { + ISO8601d now; + if (now < date) + minimum = maximum = ISO8601p (date - now).formatVague ().length (); + else + minimum = maximum = ISO8601p (now - date).formatVague ().length () + 1; + } else if (_style == "remaining") { ISO8601d now; @@ -177,6 +187,14 @@ void ColumnTypeDate::render ( else renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ()); } + else if (_style == "relative") + { + ISO8601d now; + if (now < date) + renderStringLeft (lines, width, color, ISO8601p (date - now).formatVague ()); + else + renderStringLeft (lines, width, color, "-" + ISO8601p (now - date).formatVague ()); + } else if (_style == "remaining") {