tvplanit: Fix WeekView switching to next day when a new event is created after 23:00 real time.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8430 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-08-30 21:54:32 +00:00
parent dcfa500d6e
commit 398734211f

View File

@ -1129,7 +1129,11 @@ begin
if (DataStore.Resource <> nil) then begin if (DataStore.Resource <> nil) then begin
{ otherwise, we must want to create a new event } { otherwise, we must want to create a new event }
StartTime := NextFullHour(FActiveDate + Time()); StartTime := NextFullHour(FActiveDate + Time());
// StartTime := trunc(Date) + 0.5; { default to 12:00 noon } // Be careful: By taking the next full hour we may advance to the next day
// here which is very confusing to the user who had dbl-clicked on the
// previous day. In this case we go back by one hour (--> 23:00)
if trunc(StartTime) <> FActiveDate then
StartTime := StartTime - OneHour;
EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes } EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes }
ActiveEvent := DataStore.Resource.Schedule.AddEvent( ActiveEvent := DataStore.Resource.Schedule.AddEvent(
DataStore.GetNextID('Events'), DataStore.GetNextID('Events'),
@ -1392,6 +1396,11 @@ begin
Exit; Exit;
StartTime := NextFullHour(Now()); { Default start time: next full hour } StartTime := NextFullHour(Now()); { Default start time: next full hour }
// Be careful: By taking the next full hour we may advance to the next day
// here which is very confusing to the user who had clicked on the
// previous day. In this case we go back by one hour (--> 23:00)
if Trunc(StartTime) <> FActiveDate then
StartTime := StartTime - OneHour;
EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes } EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes }
ActiveEvent := DataStore.Resource.Schedule.AddEvent( ActiveEvent := DataStore.Resource.Schedule.AddEvent(
DataStore.GetNextID('Events'), DataStore.GetNextID('Events'),