Explorar el Código

reduced time strings to 2 units (e.g. 2 day 12 hours)

Wolfgang Ortmann hace 9 años
padre
commit
5b2d445ba1
Se han modificado 2 ficheros con 395 adiciones y 365 borrados
  1. 380 360
      src/kind.cpp
  2. 15 5
      src/stringtools.cpp

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 380 - 360
src/kind.cpp


+ 15 - 5
src/stringtools.cpp

@@ -210,13 +210,23 @@ string timeString(time_t t)
   int hour = t % 24;
   t /= 24;
   int days = t;
+  int nParts = 0;
   if (days > 0)
-    res += to_string(days) + " days ";
+    {
+      res += to_string(days) + " days ";
+      nParts++;
+    }
   if (hour > 0)
-    res += to_string(hour) + " hours ";
-  if (min > 0)
-    res += to_string(min) + " minutes ";
-  if (sec > 0 || res.empty())
+    {
+      res += to_string(hour) + " hours ";
+      nParts++;
+    }
+  if (min > 0 && nParts < 2)
+    {
+      res += to_string(min) + " minutes ";
+      nParts++;
+    }
+  if ((sec > 0 && nParts < 2) || nParts == 0)
     res += to_string(sec) + " seconds ";
   return res;
 }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio