ex100.pp 626 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. Program Example100;
  2. { This program demonstrates the CompareTime 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),' has ');
  11. Cmp:=CompareDateTime(D1,D2);
  12. If Cmp<0 then
  13. write('earlier time than ')
  14. else if Cmp>0 then
  15. Write('later time than ')
  16. else
  17. Write('equal time with ');
  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(N+1,N);
  28. Test(N-1,N);
  29. Test(N+OneSecond,N);
  30. Test(N-OneSecond,N);
  31. End.