Code Cleanup - removed formatTimeDeltaDays

- Removed util.cpp/formatTimeDeltaDays, as it was a replica of
  util.cpp/formatSeconds with a different signature.  Worthless.
This commit is contained in:
Paul Beckingham 2009-06-03 00:58:49 -04:00
parent 9eb68881af
commit 4ede817ead
3 changed files with 4 additions and 55 deletions

View file

@ -512,7 +512,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
if (created.length ())
{
Date dt (::atoi (created.c_str ()));
formatTimeDeltaDays (age, (time_t) (now - dt));
age = formatSeconds ((time_t) (now - dt));
}
table.addCell (row, 1, entry + " (" + age + ")");
@ -644,7 +644,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
if (counter[i->first])
{
std::string age;
formatTimeDeltaDays (age, (time_t) (sumEntry[i->first] / counter[i->first]));
age = formatSeconds ((time_t) (sumEntry[i->first] / counter[i->first]));
table.addCell (row, 2, age);
}
@ -820,7 +820,7 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf)
if (created.length ())
{
Date dt (::atoi (created.c_str ()));
formatTimeDeltaDays (age, (time_t) (now - dt));
age = formatSeconds ((time_t) (now - dt));
}
// All criteria match, so add refTask to the output table.
@ -2664,7 +2664,7 @@ std::string handleCustomReport (
if (created.length ())
{
Date dt (::atoi (created.c_str ()));
formatTimeDeltaDays (age, (time_t) (now - dt));
age = formatSeconds ((time_t) (now - dt));
table.addCell (row, columnCount, age);
}
}

View file

@ -81,56 +81,6 @@ void delay (float f)
////////////////////////////////////////////////////////////////////////////////
// Convert a quantity in seconds to a more readable format.
// Long version:
// 0-59 S seconds
// 60-3599 M minutes, S seconds
// 3600-86399 H hours, M minutes, S seconds
// 86400- D days, H hours, M minutes, S seconds
// Short version:
// 0-59 S seconds
// 60-3599 M minutes, S seconds
// 3600-86399 H hours, M minutes, S seconds
//
void formatTimeDeltaDays (std::string& output, time_t delta)
{
char formatted[24];
float days = (float) delta / 86400.0;
if (days > 365)
sprintf (formatted, "%.1f yrs", (days / 365.2422));
else if (days > 84)
sprintf (formatted, "%1d mth%s",
(int) (days / 30.6),
((int) (days / 30.6) == 1 ? "" : "s"));
else if (days > 13)
sprintf (formatted, "%d wk%s",
(int) (days / 7.0),
((int) (days / 7.0) == 1 ? "" : "s"));
else if (days > 5.0)
sprintf (formatted, "%d day%s",
(int) days,
((int) days == 1 ? "" : "s"));
else if (days > 1.0)
sprintf (formatted, "%.1f days", days);
else if (days * 24 > 1.0)
sprintf (formatted, "%d hr%s",
(int) (days * 24.0),
((int) (days * 24.0) == 1 ? "" : "s"));
else if (days * 24 * 60 > 1)
sprintf (formatted, "%d min%s",
(int) (days * 24 * 60),
((int) (days * 24 * 60) == 1 ? "" : "s"));
else if (days * 24 * 60 * 60 > 1)
sprintf (formatted, "%d sec%s",
(int) (days * 24 * 60 * 60),
((int) (days * 24 * 60 * 60) == 1 ? "" : "s"));
else
strcpy (formatted, "-");
output = formatted;
}
////////////////////////////////////////////////////////////////////////////////
std::string formatSeconds (time_t delta)
{
char formatted[24];

View file

@ -52,7 +52,6 @@ for (typeof (c) *foreach_p = & (c); \
// util.cpp
bool confirm (const std::string&);
void delay (float);
void formatTimeDeltaDays (std::string&, time_t);
std::string formatSeconds (time_t);
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&);
const std::string uuid ();