diff --git a/ChangeLog b/ChangeLog index 3142cbc09..a098cae4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ (thanks to James Dietrich). - TW-1446 Difference in how relative dates are specified in report filters since 2.3.0 (thanks to atomicules). +- TW-1500 Dates formatted as ".age", ".remaining", or ".countdown" often give + blank results (thanks to Jeremy John Reeder). - TW-1582 Wrong urgency for first report after reviving task with "mod status:pending" - TW-1698 tests: 'make test' should exit non-zero if tests failed diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index 8a470405c..4e11f6d10 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -92,7 +92,8 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m else if (_style == "countdown") { ISO8601d now; - minimum = maximum = ISO8601p (now - date).formatVague ().length (); + if (now > date) + minimum = maximum = ISO8601p (now - date).formatVague ().length (); } else if (_style == "julian") { @@ -109,7 +110,10 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m else if (_style == "age") { ISO8601d now; - minimum = maximum = ISO8601p (now - date).formatVague ().length (); + if (now > date) + minimum = maximum = ISO8601p (now - date).formatVague ().length (); + else + minimum = maximum = ISO8601p (date - now).formatVague ().length () + 1; } else if (_style == "remaining") { @@ -153,7 +157,8 @@ void ColumnTypeDate::render ( else if (_style == "countdown") { ISO8601d now; - renderStringRight (lines, width, color, ISO8601p (now - date).formatVague ()); + if (now > date) + renderStringRight (lines, width, color, ISO8601p (now - date).formatVague ()); } else if (_style == "julian") renderStringRight (lines, width, color, format (date.toJulian (), 13, 12)); @@ -167,7 +172,10 @@ void ColumnTypeDate::render ( else if (_style == "age") { ISO8601d now; - renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ()); + if (now > date) + renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ()); + else + renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ()); } else if (_style == "remaining") diff --git a/test/columns.t b/test/columns.t index 8cce2e74f..cc226bfdf 100755 --- a/test/columns.t +++ b/test/columns.t @@ -373,7 +373,7 @@ class TestDateFormats(TestCase): """Verify due.age formatting""" code, out, err = self.t("xxx rc.report.xxx.columns:id,due.age") self.assertRegexpMatches(out, r'1\s+1d') - self.assertRegexpMatches(out, r'2$') + self.assertRegexpMatches(out, r'2\s+-16h') def test_date_format_remaining(self): """Verify due.remaining formatting"""