TvPlanIt: More robust comparison of TTime variables.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8173 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2021-12-13 21:25:57 +00:00
parent ed6fcb4083
commit a94f08651f
2 changed files with 10 additions and 1 deletions

View File

@ -1930,7 +1930,7 @@ begin
ThisTime := 0.0; ThisTime := 0.0;
while (J < EventList.Count) and (J < MaxVisibleEvents) do begin while (J < EventList.Count) and (J < MaxVisibleEvents) do begin
event := EventList[J]; event := EventList[J];
if frac(event.StartTime) >= thisTime then begin if SameTime(frac(event.StartTime), thisTime) or (frac(event.StartTime) > thisTime) then begin
thisTime := frac(event.EndTime); thisTime := frac(event.EndTime);
{ Handle end times of midnight } { Handle end times of midnight }
if thisTime = 0 then if thisTime = 0 then

View File

@ -146,6 +146,7 @@ function GetJulianDate(Date: TDateTime): Word;
function GetWeekOfYear(ADate: TDateTime): byte; function GetWeekOfYear(ADate: TDateTime): byte;
function IsWeekEnd(ADate: TDateTime): Boolean; function IsWeekEnd(ADate: TDateTime): Boolean;
function SameDate(dt1, dt2: TDateTime): Boolean; function SameDate(dt1, dt2: TDateTime): Boolean;
function SameTime(t1, t2: TTime): Boolean;
function DateInRange(ADate, StartDate, EndDate: TDateTime; IncludeLimits: Boolean): Boolean; function DateInRange(ADate, StartDate, EndDate: TDateTime; IncludeLimits: Boolean): Boolean;
function TimeInRange(ATime, StartTime, EndTime: TDateTime; IncludeLimits: Boolean): Boolean; function TimeInRange(ATime, StartTime, EndTime: TDateTime; IncludeLimits: Boolean): Boolean;
@ -804,6 +805,14 @@ begin
Result := trunc(dt1) = trunc(dt2); Result := trunc(dt1) = trunc(dt2);
end; end;
{ Checks whether the two time values equal within a tolerance of 1 ms }
function SameTime(t1, t2: TTime): Boolean;
const
ONE_MILLISECOND = 1.0/(24*60*60*1000);
begin
Result := SameValue(t1, t2, ONE_MILLISECOND);
end;
// Calculates ISO week number (checked with Jan 1, 2016, which is in week 53). // Calculates ISO week number (checked with Jan 1, 2016, which is in week 53).
function GetWeekOfYear(ADate: TDateTime): byte; function GetWeekOfYear(ADate: TDateTime): byte;
// wp: was in TvWeekView. // wp: was in TvWeekView.