mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-26 11:58:20 +02:00
41 lines
657 B
ObjectPascal
41 lines
657 B
ObjectPascal
Program Example98;
|
|
|
|
{ This program demonstrates the CompareDateTime 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),' is ');
|
|
Cmp:=CompareDateTime(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. |