示例#1
0
            public static UnpackedTime FromSeconds(double seconds)
            {
                UnpackedTime time = new UnpackedTime();

                time.years = (int)(seconds / SecondsPerYear);

                seconds %= SecondsPerYear;

                time.days = (int)(seconds / SecondsPerDay);

                seconds %= SecondsPerDay;

                time.hours = (int)(seconds / SecondsPerHour);

                seconds %= SecondsPerHour;

                time.minutes = (int)(seconds / SecondsPerMinute);

                seconds %= SecondsPerMinute;

                time.seconds = seconds;

                return(time);
            }
示例#2
0
 /// <summary>
 /// Formats the date given in seconds since epoch as a human-friendly
 /// date in the format YY, DD, HH:MM:SS
 /// </summary>
 /// <returns>The date.</returns>
 /// <param name="seconds">Seconds.</param>
 public static string FormatDate(double seconds)
 {
     return(UnpackedTime.FromSeconds(seconds).FormatAsDate());
 }
示例#3
0
 /// <summary>
 /// Formats the interval given in seconds as 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 FormatInterval(double seconds)
 {
     return(UnpackedTime.FromSeconds(seconds).FormatAsSpan());
 }