Beispiel #1
0
        public static string format_time(double d)
        {
            string s = "00:00:00.0";

            if (d < 0)
            {
                return(s);
            }
            int[] time = KSPUtil.GetDateFromUT((int)d);
            /* time = (seconds, minutes, hours, days, years) */
            float seconds = (float)d % 60;

            if ((time[4] == 0) && (time[3] == 0))
            {
                s = String.Format("{0:00}:{1:00}:{2:00.0}", time[2], time[1], seconds);
            }
            else if (time[4] == 0)
            {
                s = String.Format("{0:0}d {1:00}:{2:00}:{3:00}",
                                  time [3], time [2], time [1], seconds);
            }
            else
            {
                s = String.Format("{0:0}y {1:0}d {2:00}:{3:00}:{4:00}",
                                  time[4], time [3], time [2], time [1], seconds);
            }
            return(s);
        }
        internal static string timeInDays(double D)
        {
            if (D <= 0)
            {
                return("----");
            }

            int[]  time = KSPUtil.GetDateFromUT((int)D);
            string s    = "";

            if (time[4] > 0)
            {
                s = string.Format("{0}y", time[4]);
            }
            if (time[3] > 0)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    s += " ";
                }
                s += string.Format("{0}d", time[3]);
            }
            if (time[4] <= 0 && time[2] > 0)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    s += " ";
                }
                s += string.Format("{0}h", time[2]);
            }
            if (time[4] <= 0 && time[3] <= 0 && time[2] <= 0 && time[1] > 0)
            {
                s = string.Format("{0}m", time[1]);
            }

            return(s);
        }