VOID_Tools: Fixed ConvertInterval to use Kerbin days and years when so selected in the game settings.
VOID_Tools: Fixed ConvertInterval to use Kerbin days and years when so selected in the game settings.

--- a/VOID.csproj
+++ b/VOID.csproj
@@ -12,6 +12,8 @@
     <UseMSBuildEngine>False</UseMSBuildEngine>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ReleaseVersion>0.11</ReleaseVersion>
+    <SynchReleaseVersion>false</SynchReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_win|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>

--- a/VOID_Core.cs
+++ b/VOID_Core.cs
@@ -81,7 +81,7 @@
 		 * Fields
 		 * */
 		protected string VoidName = "VOID";
-		protected string VoidVersion = "0.10.0";
+		protected string VoidVersion = "0.11.0";
 
 		protected bool _factoryReset = false;
 

--- a/VOID_Orbital.cs
+++ b/VOID_Orbital.cs
@@ -129,7 +129,14 @@
 	{
 		public static readonly VOID_StrValue primaryName = new VOID_StrValue (
 			VOID_Localization.void_primary,
-			new Func<string> (() => VOID_Core.Instance.vessel.mainBody.name)
+			delegate()
+		{
+			if (VOID_Core.Instance.vessel == null)
+			{
+				return string.Empty;
+			}
+			return VOID_Core.Instance.vessel.mainBody.name;
+		}
 		);
 
 		public static readonly VOID_DoubleValue orbitAltitude = new VOID_DoubleValue (

--- a/VOID_Tools.cs
+++ b/VOID_Tools.cs
@@ -111,6 +111,11 @@
 
 		public static ExperimentSituations GetExperimentSituation(this Vessel vessel)
 		{
+			if (vessel == null)
+			{
+				return ExperimentSituations.SrfSplashed;
+			}
+
 			Vessel.Situations situation = vessel.situation;
 
 			switch (situation)
@@ -251,54 +256,69 @@
 		}
 		#endregion
 
+		/// <summary>
+		/// Converts the interval given in seconds to a human-friendly
+		/// time period in [years], [days], hours, minutes, and seconds.
+		/// 
+		/// Uses sidereal days, since "6 hours per day" is the Kerbal standard.
+		/// </summary>
+		/// <returns>Human readable interval</returns>
+		/// <param name="seconds"></param>
 		public static string ConvertInterval(double seconds)
 		{
-			string format_1 = "{0:D1}y {1:D1}d {2:D2}h {3:D2}m {4:D2}.{5:D1}s";
-			string format_2 = "{0:D1}d {1:D2}h {2:D2}m {3:D2}.{4:D1}s";
-			string format_3 = "{0:D2}h {1:D2}m {2:D2}.{3:D1}s";
-
-			TimeSpan interval;
-
-			try
-			{
-				interval = TimeSpan.FromSeconds(seconds);
-			}
-			catch (OverflowException)
-			{
-				return "NaN";
-			}
-
-			int years = interval.Days / 365;
-
-			string output;
+			double SecondsPerMinute = 60d;
+			double SecondsPerHour = 3600d;
+			double SecondsPerDay;
+			double SecondsPerYear;
+
+			if (GameSettings.KERBIN_TIME)
+			{
+				SecondsPerDay = 21600d;
+				SecondsPerYear = 9203545d;
+			}
+			else
+			{
+				SecondsPerDay = 86164.1d;
+				SecondsPerYear = 31558149d;
+			}
+
+			int years;
+			int days;
+			int hours;
+			int minutes;
+
+			years = (int)(seconds / SecondsPerYear);
+
+			seconds %= SecondsPerYear;
+
+			days = (int)(seconds / SecondsPerDay);
+
+			seconds %= SecondsPerDay;
+
+			hours = (int)(seconds / SecondsPerHour);
+
+			seconds %= SecondsPerHour;
+
+			minutes = (int)(seconds / SecondsPerMinute);
+
+			seconds %= SecondsPerMinute;
+
+			string format_1 = "{0:D1}y {1:D1}d {2:D2}h {3:D2}m {4:00.0}s";
+			string format_2 = "{0:D1}d {1:D2}h {2:D2}m {3:00.0}s";
+			string format_3 = "{0:D2}h {1:D2}m {2:00.0}s";
+
 			if (years > 0)
 			{
-				output = string.Format(format_1,
-					years,
-					interval.Days - (years * 365), //  subtract years * 365 for accurate day count
-					interval.Hours,
-					interval.Minutes,
-					interval.Seconds,
-					interval.Milliseconds.ToString().Substring(0, 1));
-			}
-			else if (interval.Days > 0)
-			{
-				output = string.Format(format_2,
-					interval.Days,
-					interval.Hours,
-					interval.Minutes,
-					interval.Seconds,
-					interval.Milliseconds.ToString().Substring(0, 1));
+				return string.Format(format_1, years, days, hours, minutes, seconds);
+			}
+			else if (days > 0)
+			{
+				return string.Format(format_2, days, hours, minutes, seconds);
 			}
 			else
 			{
-				output = string.Format(format_3,
-					interval.Hours,
-					interval.Minutes,
-					interval.Seconds,
-					interval.Milliseconds.ToString().Substring(0, 1));
-			}
-			return output;
+				return string.Format(format_3, hours, minutes, seconds);
+			}
 		}
 
 		public static string UppercaseFirst(string s)