ex98.pp 657 B

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