- 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:
Paul Beckingham 2011-08-23 22:15:00 -04:00
parent 89d3b4e805
commit 2f60bdf9d0
6 changed files with 44 additions and 2 deletions

View file

@ -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)
{

View file

@ -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&);

View file

@ -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 ()));
}
}