TW-1500: Dates formatted as ".age", ".remaining", or ".countdown" often give blank results

- The 'age' column regained the ability to show negative durations.
- The 'countdown' and 'remaining' continue to show only positive values, by
  design.
- Thanks to Jeremy John Reeder.
This commit is contained in:
Paul Beckingham 2015-11-16 07:41:41 -05:00
parent f71630a416
commit ba098d790f
3 changed files with 15 additions and 5 deletions

View file

@ -8,6 +8,8 @@
(thanks to James Dietrich). (thanks to James Dietrich).
- TW-1446 Difference in how relative dates are specified in report filters since 2.3.0 - TW-1446 Difference in how relative dates are specified in report filters since 2.3.0
(thanks to atomicules). (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 - TW-1582 Wrong urgency for first report after reviving task with
"mod status:pending" "mod status:pending"
- TW-1698 tests: 'make test' should exit non-zero if tests failed - TW-1698 tests: 'make test' should exit non-zero if tests failed

View file

@ -92,6 +92,7 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m
else if (_style == "countdown") else if (_style == "countdown")
{ {
ISO8601d now; ISO8601d now;
if (now > date)
minimum = maximum = ISO8601p (now - date).formatVague ().length (); minimum = maximum = ISO8601p (now - date).formatVague ().length ();
} }
else if (_style == "julian") else if (_style == "julian")
@ -109,7 +110,10 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m
else if (_style == "age") else if (_style == "age")
{ {
ISO8601d now; ISO8601d now;
if (now > date)
minimum = maximum = ISO8601p (now - date).formatVague ().length (); minimum = maximum = ISO8601p (now - date).formatVague ().length ();
else
minimum = maximum = ISO8601p (date - now).formatVague ().length () + 1;
} }
else if (_style == "remaining") else if (_style == "remaining")
{ {
@ -153,6 +157,7 @@ void ColumnTypeDate::render (
else if (_style == "countdown") else if (_style == "countdown")
{ {
ISO8601d now; ISO8601d now;
if (now > date)
renderStringRight (lines, width, color, ISO8601p (now - date).formatVague ()); renderStringRight (lines, width, color, ISO8601p (now - date).formatVague ());
} }
else if (_style == "julian") else if (_style == "julian")
@ -167,7 +172,10 @@ void ColumnTypeDate::render (
else if (_style == "age") else if (_style == "age")
{ {
ISO8601d now; ISO8601d now;
if (now > date)
renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ()); renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ());
else
renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ());
} }
else if (_style == "remaining") else if (_style == "remaining")

View file

@ -373,7 +373,7 @@ class TestDateFormats(TestCase):
"""Verify due.age formatting""" """Verify due.age formatting"""
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.age") code, out, err = self.t("xxx rc.report.xxx.columns:id,due.age")
self.assertRegexpMatches(out, r'1\s+1d') 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): def test_date_format_remaining(self):
"""Verify due.remaining formatting""" """Verify due.remaining formatting"""