diff --git a/ChangeLog b/ChangeLog index a098cae4c..ee3ca1049 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ (thanks to Michele Santullo). - TW-1313 some recurring intervals reset due time to midnight (thanks to James Dietrich). +- TW-1425 The 'age' format rounds in odd ways (thanks to Black Ops testing). - 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 diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 91eb9bee9..870359346 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -1951,14 +1951,24 @@ const std::string ISO8601p::format () const } //////////////////////////////////////////////////////////////////////////////// +// Range Representation +// --------- --------------------- +// >= 365d {n.n}y +// >= 90d {n}mo +// >= 14d {n}w +// >= 1d {n}d +// >= 1h {n}h +// >= 1min {n}min +// {n}s +// const std::string ISO8601p::formatVague () const { float days = (float) _period / 86400.0; std::stringstream formatted; if (_period >= 86400 * 365) formatted << std::fixed << std::setprecision (1) << (days / 365) << "y"; - else if (_period >= 86400 * 84) formatted << static_cast (days / 30) << "mo"; - else if (_period >= 86400 * 13) formatted << static_cast (days / 7) << "w"; + else if (_period >= 86400 * 90) formatted << static_cast (days / 30) << "mo"; + else if (_period >= 86400 * 14) formatted << static_cast (days / 7) << "w"; else if (_period >= 86400) formatted << static_cast (days) << "d"; else if (_period >= 3600) formatted << static_cast (_period / 3600) << "h"; else if (_period >= 60) formatted << static_cast (_period / 60) << "min"; diff --git a/test/columns.t b/test/columns.t index cc226bfdf..e6409610b 100755 --- a/test/columns.t +++ b/test/columns.t @@ -372,8 +372,8 @@ class TestDateFormats(TestCase): def test_date_format_age(self): """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\s+-16h') + self.assertRegexpMatches(out, r'1\s+[0-9.]+d') + self.assertRegexpMatches(out, r'2\s+-[0-9.]+h') def test_date_format_remaining(self): """Verify due.remaining formatting"""