mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-04 03:18:33 +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
|
@ -283,6 +283,22 @@ std::string Duration::formatCompact () const
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
std::string format () const;
|
||||
std::string formatCompact () const;
|
||||
std::string formatPrecise () const;
|
||||
|
||||
bool negative () const;
|
||||
static bool valid (const std::string&);
|
||||
|
|
|
@ -386,7 +386,7 @@ int CmdInfo::execute (std::string& output)
|
|||
{
|
||||
row = journal.addRow ();
|
||||
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 ()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue