tvplanit: More round-off-error-tolerant version of TimeInRange function
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4750 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
faca8ece98
commit
6827b11c3a
@ -77,6 +77,7 @@ const
|
||||
calDefWidth = 200; { popup calendar default width }
|
||||
ExtraBarWidth = 2; { The extra, draggable area on either side }
|
||||
{ of the Contact Grid's horizontal bars. }
|
||||
CompareTimeEPS = 1.0 / (24*60*60*10); { Epsilon for time comparison, 0.1 sec }
|
||||
|
||||
ResourceTableName = 'Resources';
|
||||
TasksTableName = 'Tasks';
|
||||
|
@ -3766,9 +3766,9 @@ begin
|
||||
|
||||
{ Initialize some stuff }
|
||||
if TimeFormat = tf24Hour then
|
||||
Format := 'h:mm'
|
||||
Format := 'h:nn'
|
||||
else
|
||||
Format := 'h:mmam/pm';
|
||||
Format := 'h:nnam/pm';
|
||||
|
||||
{ set the event array's size }
|
||||
SetLength(EventArray, MaxVisibleEvents);
|
||||
|
@ -534,11 +534,18 @@ end;
|
||||
|
||||
function TimeInRange(Time, StartTime, EndTime: TDateTime;
|
||||
Inclusive: Boolean): Boolean;
|
||||
var
|
||||
equStart, equEnd: Boolean;
|
||||
begin
|
||||
equStart := abs(Time - StartTime) < CompareTimeEps;
|
||||
equEnd := abs(Time - EndTime) < CompareTimeEps;
|
||||
|
||||
if Inclusive then
|
||||
result := (Time >= StartTime) and (Time <= EndTime)
|
||||
Result := equStart or equEnd or ((Time > StartTime) and (Time < EndTime))
|
||||
// result := (Time >= StartTime) and (Time <= EndTime)
|
||||
else
|
||||
result := (Time > StartTime) and (Time < EndTime);
|
||||
Result := (not equStart) and (not equEnd) and (Time > StartTime) and (Time < EndTime);
|
||||
// result := (Time > StartTime) and (Time < EndTime);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user