mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TW-1425: The 'age' format rounds in odd ways
- While duration formats are still not configurable, the break points for formatting units is shifted to be a little more predictable. - Thanks to Black Ops testing.
This commit is contained in:
parent
ba098d790f
commit
253fd35dc7
3 changed files with 15 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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 <int> (days / 30) << "mo";
|
||||
else if (_period >= 86400 * 13) formatted << static_cast <int> (days / 7) << "w";
|
||||
else if (_period >= 86400 * 90) formatted << static_cast <int> (days / 30) << "mo";
|
||||
else if (_period >= 86400 * 14) formatted << static_cast <int> (days / 7) << "w";
|
||||
else if (_period >= 86400) formatted << static_cast <int> (days) << "d";
|
||||
else if (_period >= 3600) formatted << static_cast <int> (_period / 3600) << "h";
|
||||
else if (_period >= 60) formatted << static_cast <int> (_period / 60) << "min";
|
||||
|
|
|
@ -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"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue