mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug #720
- Fixed bug #720, so that when the 'info' report renders total active time, it uses a lossless format (thanks to Bernhard B).
This commit is contained in:
parent
89d3b4e805
commit
2f60bdf9d0
6 changed files with 44 additions and 2 deletions
1
AUTHORS
1
AUTHORS
|
@ -108,4 +108,5 @@ suggestions:
|
||||||
Yann Davin
|
Yann Davin
|
||||||
John Hammond
|
John Hammond
|
||||||
Arkady Grudzinsky
|
Arkady Grudzinsky
|
||||||
|
Bernhard B
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,8 @@
|
||||||
(thanks to Michelle Crane).
|
(thanks to Michelle Crane).
|
||||||
+ Fixed bug #713, which fixes typos in the holidays-UK.rc file (thanks to
|
+ Fixed bug #713, which fixes typos in the holidays-UK.rc file (thanks to
|
||||||
Alexei Romanoff).
|
Alexei Romanoff).
|
||||||
|
+ Fixed bug #720, so that when the 'info' report renders total active time,
|
||||||
|
it uses a lossless format (thanks to Bernhard B).
|
||||||
+ Fixed bug #723, which displayed a misleading message when the output was
|
+ Fixed bug #723, which displayed a misleading message when the output was
|
||||||
truncated to a page.
|
truncated to a page.
|
||||||
+ Fixed bug #732, which fixes misleading messages and documentation for
|
+ Fixed bug #732, which fixes misleading messages and documentation for
|
||||||
|
|
|
@ -283,6 +283,22 @@ std::string Duration::formatCompact () const
|
||||||
return std::string (formatted);
|
return std::string (formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string Duration::formatPrecise () const
|
||||||
|
{
|
||||||
|
char formatted[24];
|
||||||
|
|
||||||
|
int days = mSecs / 86400;
|
||||||
|
int hours = (mSecs % 86400) / 3600;
|
||||||
|
int minutes = (mSecs % 3600) / 60;
|
||||||
|
int seconds = mSecs % 60;
|
||||||
|
|
||||||
|
if (days > 0) sprintf (formatted, "%s%dd %d:%02d:%02d", (mNegative ? "-" : ""), days, hours, minutes, seconds);
|
||||||
|
else sprintf (formatted, "%s%d:%02d:%02d", (mNegative ? "-" : ""), hours, minutes, seconds);
|
||||||
|
|
||||||
|
return std::string (formatted);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Duration::operator< (const Duration& other)
|
bool Duration::operator< (const Duration& other)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
std::string format () const;
|
std::string format () const;
|
||||||
std::string formatCompact () const;
|
std::string formatCompact () const;
|
||||||
|
std::string formatPrecise () const;
|
||||||
|
|
||||||
bool negative () const;
|
bool negative () const;
|
||||||
static bool valid (const std::string&);
|
static bool valid (const std::string&);
|
||||||
|
|
|
@ -386,7 +386,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = journal.addRow ();
|
row = journal.addRow ();
|
||||||
journal.set (row, 0, STRING_CMD_INFO_TOTAL_ACTIVE);
|
journal.set (row, 0, STRING_CMD_INFO_TOTAL_ACTIVE);
|
||||||
journal.set (row, 1, Duration (total_time).format (),
|
journal.set (row, 1, Duration (total_time).formatPrecise (),
|
||||||
(context.color () ? Color ("bold") : Color ()));
|
(context.color () ? Color ("bold") : Color ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ int convertDuration (const std::string& input)
|
||||||
|
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (631);
|
UnitTest t (651);
|
||||||
|
|
||||||
Duration d;
|
Duration d;
|
||||||
|
|
||||||
|
@ -102,6 +102,28 @@ int main (int argc, char** argv)
|
||||||
d = Duration (365 * 86400), t.is (d.formatCompact (), "1.0y", "365 days -> 1.0y");
|
d = Duration (365 * 86400), t.is (d.formatCompact (), "1.0y", "365 days -> 1.0y");
|
||||||
d = Duration (365 * 86400 + 1), t.is (d.formatCompact (), "1.0y", "365 days + 1 sec -> 1.0y");
|
d = Duration (365 * 86400 + 1), t.is (d.formatCompact (), "1.0y", "365 days + 1 sec -> 1.0y");
|
||||||
|
|
||||||
|
// std::string formatPrecise ();
|
||||||
|
d = Duration (0), t.is (d.formatPrecise (), "0:00:00", "0 -> 0:00:00");
|
||||||
|
d = Duration (1), t.is (d.formatPrecise (), "0:00:01", "1 -> 0:00:01");
|
||||||
|
d = Duration (2), t.is (d.formatPrecise (), "0:00:02", "2 -> 0:00:02");
|
||||||
|
d = Duration (59), t.is (d.formatPrecise (), "0:00:59", "59 -> 0:00:59");
|
||||||
|
d = Duration (60), t.is (d.formatPrecise (), "0:01:00", "60 -> 0:01;00");
|
||||||
|
d = Duration (119), t.is (d.formatPrecise (), "0:01:59", "119 -> 0:01:59");
|
||||||
|
d = Duration (120), t.is (d.formatPrecise (), "0:02:00", "120 -> 0:02:00");
|
||||||
|
d = Duration (121), t.is (d.formatPrecise (), "0:02:01", "121 -> 0:02:01");
|
||||||
|
d = Duration (3599), t.is (d.formatPrecise (), "0:59:59", "3599 -> 0:59:59");
|
||||||
|
d = Duration (3600), t.is (d.formatPrecise (), "1:00:00", "3600 -> 1:00:00");
|
||||||
|
d = Duration (3601), t.is (d.formatPrecise (), "1:00:01", "3601 -> 1:00:01");
|
||||||
|
d = Duration (86399), t.is (d.formatPrecise (), "23:59:59", "86399 -> 23:59:59");
|
||||||
|
d = Duration (86400), t.is (d.formatPrecise (), "1d 0:00:00", "86400 -> 1d 0:00:00");
|
||||||
|
d = Duration (86401), t.is (d.formatPrecise (), "1d 0:00:01", "86401 -> 1d 0:00:01");
|
||||||
|
d = Duration (14 * 86400 - 1), t.is (d.formatPrecise (), "13d 23:59:59", "(14 * 86400) - 1 sec -> 13d 23:59:59");
|
||||||
|
d = Duration (14 * 86400), t.is (d.formatPrecise (), "14d 0:00:00", "(14 * 86400) -> 14d 0:00:00");
|
||||||
|
d = Duration (14 * 86400 + 1), t.is (d.formatPrecise (), "14d 0:00:01", "(14 * 86400) + 1 -> 14d 0:00:01");
|
||||||
|
d = Duration (365 * 86400 - 1), t.is (d.formatPrecise (), "364d 23:59:59", "365 days - 1 sec -> 364d 23:59:59");
|
||||||
|
d = Duration (365 * 86400), t.is (d.formatPrecise (), "365d 0:00:00", "365 days -> 365d 0:00:00");
|
||||||
|
d = Duration (365 * 86400 + 1), t.is (d.formatPrecise (), "365d 0:00:01", "365 days + 1 sec -> 365d 0:00:01");
|
||||||
|
|
||||||
// Iterate for a whole year. Why? Just to see where the boundaries are,
|
// Iterate for a whole year. Why? Just to see where the boundaries are,
|
||||||
// so that changes can be made with some reference point.
|
// so that changes can be made with some reference point.
|
||||||
d = Duration ( 1*86400), t.is (d.formatCompact (), "1d", "1*86400 -> 1d");
|
d = Duration ( 1*86400), t.is (d.formatCompact (), "1d", "1*86400 -> 1d");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue