From 4ede817eadf065a3a6d21da8d1496db2d6d040b4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 3 Jun 2009 00:58:49 -0400 Subject: [PATCH] Code Cleanup - removed formatTimeDeltaDays - Removed util.cpp/formatTimeDeltaDays, as it was a replica of util.cpp/formatSeconds with a different signature. Worthless. --- src/report.cpp | 8 ++++---- src/util.cpp | 50 -------------------------------------------------- src/util.h | 1 - 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/src/report.cpp b/src/report.cpp index 168201db2..73912b0f3 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -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); } } diff --git a/src/util.cpp b/src/util.cpp index 8cbb9cfe2..4a09a420f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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]; diff --git a/src/util.h b/src/util.h index 2bfaef59a..101b04afa 100644 --- a/src/util.h +++ b/src/util.h @@ -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::vector&); const std::string uuid ();