/// <summary> /// Returns the default filename for the savegame according to the current settings /// </summary> /// <returns></returns> private string getDefaultFileName() { string result = dfltSaveNames[selectedDfltSaveName]; if (useGameTime) { var currentGameTime = Planetarium.GetUniversalTime(); var lengthOfDay = Planetarium.fetch.Home.solarDayLength; var lengthOfYear = Planetarium.fetch.Home.GetOrbit().period; var currentTimeOfHomePlanet = new PlanetTime(currentGameTime, lengthOfYear, lengthOfDay); result = result.Replace("{Time}", currentTimeOfHomePlanet.ToCompactSortableTimeStamp()); } else { result = result.Replace("{Time}", DateTime.Now.ToString("yyyyMMdd_HHmmss")); } // If we are at the space center, we can't access the name of the active vessel, as there simply is none. if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { result = result.Replace("{ActiveVessel}", "SpaceCenter"); } else { result = result.Replace("{ActiveVessel}", FlightGlobals.ActiveVessel.vesselName); } return(result); }
public void OperatorPlus_ReturnsCorrectValue(long startHour, long startMinute, long hoursToAdd, long minutesToAdd) { var start = DateTime.UnixEpoch + new TimeSpan((int)startHour, (int)startMinute, 0); var span = new TimeSpan((int)hoursToAdd, (int)minutesToAdd, 0); var end = start + span; var startPlanetTime = new PlanetTime <EarthTimeConfiguration>(startHour, startMinute); var planetTimeSpan = new PlanetTimeSpan <EarthTimeConfiguration>(hoursToAdd, minutesToAdd); var endPlanetTime = startPlanetTime + planetTimeSpan; Assert.Equal(((long)end.Hour, (long)end.Minute), endPlanetTime.ToTime()); }
public void OperatorMinus_ReturnsCorrectValue(long startHour, long startMinute, long endHour, long endMinute) { var start = DateTime.UnixEpoch + new TimeSpan((int)startHour, (int)startMinute, 0); var end = DateTime.UnixEpoch + new TimeSpan((int)endHour, (int)endMinute, 0); if (end < start) { end = end.AddDays(1); } var span = end - start; var startPlanetTime = new PlanetTime <EarthTimeConfiguration>(startHour, startMinute); var endPlanetTime = new PlanetTime <EarthTimeConfiguration>(endHour, endMinute); var planetTimeSpan = endPlanetTime - startPlanetTime; Assert.Equal(((long)span.Hours, (long)span.Minutes), planetTimeSpan.ToTime()); }
/// <summary> /// 获取大概时间 /// </summary> /// <param name="time"></param> /// <returns></returns> public YuanTime GetYuanTime(PlanetTime time) { return(RevolutionTime.Value * time.RevolutionNumber + RotationTime.Value * time.RotationNumber); }
public ComeToModels SetCurrPlanetTimeByKeyName(string key) { PlanetTime = PlanetTime.SetCurr(key); return(this); }
public static string ToEarthTime(this PlanetTime pt) { int year = (int)Math.Floor(pt.RevolutionNumber); return(string.Format("公元{0}年", year)); }