Skip to content

Commit

Permalink
avoid timewarp kraken
Browse files Browse the repository at this point in the history
  • Loading branch information
Clayell authored Feb 3, 2025
1 parent 9b8eb15 commit 0c55816
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Source/RP0/UI/KCT/GUI_Simulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ private static void StartSim(SimulationParams simParams)

double currentUT = Planetarium.GetUniversalTime();
double ut = 0;
if (!string.IsNullOrWhiteSpace(_UTString) && !ROUtils.DTUtils.TryParseTimeString(_UTString, isTimespan: !_fromCurrentUT, out ut))
// if string is not empty and ((string has HH:mm but no YYYY-MM-DD) or (string fails TryParseTimeString)), then output failure
if (!string.IsNullOrWhiteSpace(_UTString) &&
(_UTString.Contains(":") && !System.Text.RegularExpressions.Regex.IsMatch(_UTString, @"^\d{4}-\d{2}-\d{2}")) ||
!ROUtils.DTUtils.TryParseTimeString(_UTString, isTimespan: !_fromCurrentUT, out ut))
{
var message = new ScreenMessage("Please enter a valid time value.", 6f, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(message);
Expand Down

0 comments on commit 0c55816

Please sign in to comment.