Skip to content

Commit eddcc07

Browse files
committed
ColTypeDate: format "countdown" as described in example text
The "countdown" format has been the same as the "relative" format, except that negative durations are not rendered, for about a decade. (There was a minor fix in #1840.) However, the example text shows something that looks like 00:00:00. This is how "countdown" was originally rendered but this was changed as part of the "isodate" branch in 995de68. See #4013 for more information. Fixes #4013
1 parent 588931d commit eddcc07

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/columns/ColTypeDate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void ColumnTypeDate::measure(Task& task, unsigned int& minimum, unsigned int& ma
7575
minimum = maximum = Datetime::length(format);
7676
} else if (_style == "countdown") {
7777
Datetime now;
78-
minimum = maximum = Duration(date - now).formatVague(true).length();
78+
if (date > now) minimum = maximum = Duration(date - now).format().length();
7979
} else if (_style == "julian") {
8080
minimum = maximum = format(date.toJulian(), 13, 12).length();
8181
} else if (_style == "epoch") {
@@ -120,7 +120,7 @@ void ColumnTypeDate::render(std::vector<std::string>& lines, Task& task, int wid
120120
renderStringLeft(lines, width, color, date.toString(format));
121121
} else if (_style == "countdown") {
122122
Datetime now;
123-
renderStringRight(lines, width, color, Duration(date - now).formatVague(true));
123+
if (date > now) renderStringRight(lines, width, color, Duration(date - now).format());
124124
} else if (_style == "julian")
125125
renderStringRight(lines, width, color, format(date.toJulian(), 13, 12));
126126

test/columns.test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def test_date_format_countdown(self):
417417
"""Verify due.countdown formatting"""
418418
code, out, err = self.t("xxx rc.report.xxx.columns:id,due.countdown")
419419
self.assertRegex(out, r"1\s+")
420-
self.assertRegex(out, r"2\s+[0-9.]+[hmin]+")
420+
self.assertRegex(out, r"2\s+(\d+d )?\d+:\d{2}:\d{2}")
421421

422422
def test_date_format_unrecognized(self):
423423
"""Verify due.donkey formatting fails"""

0 commit comments

Comments
 (0)