You've already forked lazarus-ccr
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:
@ -77,6 +77,7 @@ const
|
|||||||
calDefWidth = 200; { popup calendar default width }
|
calDefWidth = 200; { popup calendar default width }
|
||||||
ExtraBarWidth = 2; { The extra, draggable area on either side }
|
ExtraBarWidth = 2; { The extra, draggable area on either side }
|
||||||
{ of the Contact Grid's horizontal bars. }
|
{ of the Contact Grid's horizontal bars. }
|
||||||
|
CompareTimeEPS = 1.0 / (24*60*60*10); { Epsilon for time comparison, 0.1 sec }
|
||||||
|
|
||||||
ResourceTableName = 'Resources';
|
ResourceTableName = 'Resources';
|
||||||
TasksTableName = 'Tasks';
|
TasksTableName = 'Tasks';
|
||||||
|
@ -3766,9 +3766,9 @@ begin
|
|||||||
|
|
||||||
{ Initialize some stuff }
|
{ Initialize some stuff }
|
||||||
if TimeFormat = tf24Hour then
|
if TimeFormat = tf24Hour then
|
||||||
Format := 'h:mm'
|
Format := 'h:nn'
|
||||||
else
|
else
|
||||||
Format := 'h:mmam/pm';
|
Format := 'h:nnam/pm';
|
||||||
|
|
||||||
{ set the event array's size }
|
{ set the event array's size }
|
||||||
SetLength(EventArray, MaxVisibleEvents);
|
SetLength(EventArray, MaxVisibleEvents);
|
||||||
|
@ -534,11 +534,18 @@ end;
|
|||||||
|
|
||||||
function TimeInRange(Time, StartTime, EndTime: TDateTime;
|
function TimeInRange(Time, StartTime, EndTime: TDateTime;
|
||||||
Inclusive: Boolean): Boolean;
|
Inclusive: Boolean): Boolean;
|
||||||
|
var
|
||||||
|
equStart, equEnd: Boolean;
|
||||||
begin
|
begin
|
||||||
|
equStart := abs(Time - StartTime) < CompareTimeEps;
|
||||||
|
equEnd := abs(Time - EndTime) < CompareTimeEps;
|
||||||
|
|
||||||
if Inclusive then
|
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
|
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;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user