This is a good idea, it'll work with Solar System, if kerbal.xml to edit. But this program work with Kerbal's calendar only: 6 hours in day and 426 days in year are hard-coded in current version.
This code
Calendar.cs
public class KCalendar
{
public const int Days = 426;
public const int Hours = 6;
public const int Mins = 60;
public const int Secs = 60;
public static double date_to_sec(int year, int day, int hour, int min, int sec)
{
return 9201600.0 * (year - 1) + 21600.0 * (day - 1) + 3600.0 * hour + 60.0 * min + sec;
}
public static void sec_to_date(double t, ref KDate date)
{
int sYear = Days * Hours * Mins * Secs;
int sDay = Hours * Mins * Secs;
int sHour = Mins * Secs;
int sMin = Secs;
date.year = Convert.ToInt32(Math.Truncate(t / sYear)) + 1;
date.day = Convert.ToInt32(Math.Truncate( (t - (date.year-1)*sYear) / sDay)) + 1;
date.hour = Convert.ToInt32(Math.Truncate((t - (date.year - 1) * sYear - (date.day - 1) * sDay) / sHour));
date.min = Convert.ToInt32(Math.Truncate((t - (date.year - 1) * sYear - (date.day - 1) * sDay - date.hour * sHour) / sMin));
date.sec = Convert.ToInt32(Math.Truncate(t - (date.year - 1) * sYear - (date.day - 1) * sDay - date.hour * sHour - date.min * sMin));
}
public static void DeltaDate(double t, ref KDate date)
{
int sYear = Days * Hours * Mins * Secs;
int sDay = Hours * Mins * Secs;
int sHour = Mins * Secs;
int sMin = Secs;
date.year = Convert.ToInt32(Math.Truncate(t / sYear));
date.day = Convert.ToInt32(Math.Truncate((t - (date.year) * sYear) / sDay));
date.hour = Convert.ToInt32(Math.Truncate((t - (date.year) * sYear - (date.day ) * sDay) / sHour));
date.min = Convert.ToInt32(Math.Truncate((t - (date.year) * sYear - (date.day) * sDay - date.hour * sHour) / sMin));
date.sec = Convert.ToInt32(Math.Truncate(t - (date.year) * sYear - (date.day) * sDay - date.hour * sHour - date.min * sMin));
}
}
must be changed to Solar system transfer calculations