Unit Tests - duration
- Corrected unit tests that were mistakenly using 'week' instead of 'weekly'.
This commit is contained in:
50
src/util.cpp
50
src/util.cpp
@@ -95,19 +95,31 @@ void formatTimeDeltaDays (std::string& output, time_t delta)
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
sprintf (formatted, "%d sec%s",
|
||||
(int) (days * 24 * 60 * 60),
|
||||
((int) (days * 24 * 60 * 60) == 1 ? "" : "s"));
|
||||
else
|
||||
strcpy (formatted, "-");
|
||||
|
||||
@@ -123,19 +135,31 @@ std::string formatSeconds (time_t delta)
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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) == 1 ? "" : "s"));
|
||||
sprintf (formatted, "%d hr%s",
|
||||
(int) (days * 24.0),
|
||||
((int) (days * 24) == 1 ? "" : "s"));
|
||||
else if (days * 24 * 60 > 1)
|
||||
sprintf (formatted, "%d min%s", (int) (days * 24 * 60), ((int) (days * 24 * 60) == 1 ? "" : "s"));
|
||||
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"));
|
||||
sprintf (formatted, "%d sec%s",
|
||||
(int) (days * 24 * 60 * 60),
|
||||
((int) (days * 24 * 60 * 60) == 1 ? "" : "s"));
|
||||
else
|
||||
strcpy (formatted, "-");
|
||||
|
||||
@@ -261,8 +285,8 @@ int convertDuration (const std::string& input)
|
||||
std::vector <std::string> supported;
|
||||
supported.push_back ("daily");
|
||||
supported.push_back ("day");
|
||||
supported.push_back ("weekdays");
|
||||
supported.push_back ("weekly");
|
||||
supported.push_back ("weekdays");
|
||||
supported.push_back ("sennight");
|
||||
supported.push_back ("biweekly");
|
||||
supported.push_back ("fortnight");
|
||||
|
||||
Reference in New Issue
Block a user