1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Program Example99;
{ This program demonstrates the CompareDate function }
Uses SysUtils,DateUtils;
Const
Fmt = 'dddd dd mmmm yyyy';
Procedure Test(D1,D2 : TDateTime);
Var
Cmp : Integer;
begin
Write(FormatDateTime(Fmt,D1),' is ');
Cmp:=CompareDate(D1,D2);
If Cmp<0 then
write('earlier than ')
else if Cmp>0 then
Write('later than ')
else
Write('equal to ');
Writeln(FormatDateTime(Fmt,D2));
end;
Var
D,N : TDateTime;
Begin
D:=Today;
N:=Now;
Test(D,D);
Test(N,N);
Test(D+1,D);
Test(D-1,D);
Test(D+OneSecond,D);
Test(D-OneSecond,D);
Test(N+OneSecond,N);
Test(N-OneSecond,N);
End.
|