Merge pull request #59 from itwtx/master
Merge pull request #59 from itwtx/master

Optimized time formatting

--- a/KerbalEngineer/Helpers/TimeFormatter.cs
+++ b/KerbalEngineer/Helpers/TimeFormatter.cs
@@ -58,31 +58,23 @@
         public static string ConvertToString(double seconds, string format = "F1")
         {
             var years = 0;
-            while (seconds >= SecondsPerYear)
+            var days = 0;
+            var hours = 0;
+            var minutes = 0;
+
+            if (seconds > 0)
             {
-                years++;
-                seconds -= SecondsPerYear;
-            }
+                years = (int)(seconds / SecondsPerYear);
+                seconds -= years * SecondsPerYear;
 
-            var days = 0;
-            while (seconds >= SecondsPerDay)
-            {
-                days++;
-                seconds -= SecondsPerDay;
-            }
+                days = (int)(seconds / SecondsPerDay);
+                seconds -= days * SecondsPerDay;
 
-            var hours = 0;
-            while (seconds >= SecondsPerHour)
-            {
-                hours++;
-                seconds -= SecondsPerHour;
-            }
+                hours = (int)(seconds / SecondsPerHour);
+                seconds -= hours * SecondsPerHour;
 
-            var minutes = 0;
-            while (seconds >= SecondsPerMinute)
-            {
-                minutes++;
-                seconds -= SecondsPerMinute;
+                minutes = (int)(seconds / SecondsPerMinute);
+                seconds -= minutes * SecondsPerMinute;
             }
 
             if (years > 0)