[Overview][Constants][Procedures and functions][Index] |
Compares two times of the day, disregarding the date part.
Source position: dateutil.inc line 354
function CompareTime( |
const A: TDateTime; |
const B: TDateTime |
A |
|
First time to compare |
B |
|
Second time to compare |
A negative number if A is before B, zero if they are equal, or positive A is later than B.
CompareTime compares the time parts of two timestamps A and B and returns the following results:
|
Compare 2 dates, taking into account the time of day |
|
|
Compare 2 dates, disregarding the time of day |
|
|
Check whether two TDateTime values have the same date part. |
|
|
Check whether two TDateTime values have the same time part. |
|
|
Check whether two TDateTime values have the same date and time parts. |
Program Example100; { This program demonstrates the CompareTime function } Uses SysUtils,DateUtils; Const Fmt = 'dddd dd mmmm yyyy hh:nn:ss.zzz'; Procedure Test(D1,D2 : TDateTime); Var Cmp : Integer; begin Write(FormatDateTime(Fmt,D1),' has '); Cmp:=CompareDateTime(D1,D2); If Cmp<0 then write('earlier time than ') else if Cmp>0 then Write('later time than ') else Write('equal time with '); Writeln(FormatDateTime(Fmt,D2)); end; Var D,N : TDateTime; Begin D:=Today; N:=Now; Test(D,D); Test(N,N); Test(N+1,N); Test(N-1,N); Test(N+OneSecond,N); Test(N-OneSecond,N); End.
lazarus-ccr.sourceforge.net |