Fix Adventure Start Time editing

Previously only date was editable and the time was not considered.
New logic takes first datetime, removes seconds, then adds the second
datetime's seconds.

Since the second datetime's date is 2000, 1, 1, the resulting value is
just totalseconds (since midnight) regardless of date (which is the
first datetime).
This commit is contained in:
Kaphotics
2016-02-11 23:44:50 -08:00
parent 7b380cd0aa
commit a48642cb32

View File

@@ -446,7 +446,7 @@ private void getTextBoxes()
CAL_LastSavedDate.Value = new DateTime(SAV.LastSavedYear, SAV.LastSavedMonth, SAV.LastSavedDay);
CAL_LastSavedTime.Value = new DateTime(2000, 1, 1, SAV.LastSavedHour, SAV.LastSavedMinute, 0);
CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart% 86400);
CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400);
}
private void save()
{
@@ -528,7 +528,10 @@ private void save()
// Vivillon
SAV.Vivillon = CB_Vivillon.SelectedIndex;
SAV.SecondsToStart = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds;
int seconds = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds;
seconds -= seconds%86400;
seconds += (int)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds;
SAV.SecondsToStart = seconds;
SAV.LastSavedYear = CAL_LastSavedDate.Value.Year;
SAV.LastSavedMonth = CAL_LastSavedDate.Value.Month;