From 6827b11c3ad9e40e7cec4f9eaaa61fe260a38d7f Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 14 Jun 2016 14:20:23 +0000 Subject: [PATCH] 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 --- components/tvplanit/source/vpconst.pas | 1 + components/tvplanit/source/vpdayview.pas | 4 ++-- components/tvplanit/source/vpmisc.pas | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/tvplanit/source/vpconst.pas b/components/tvplanit/source/vpconst.pas index 1cca4364d..ddd9979d6 100644 --- a/components/tvplanit/source/vpconst.pas +++ b/components/tvplanit/source/vpconst.pas @@ -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'; diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index 5305d15e8..17bda4a34 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -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); diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 2dc63fe7c..6105c1f7f 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -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; {=====}