GMTToLocalDateTimeProc.pas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 11251: GMTToLocalDateTimeProc.pas
  11. {
  12. { Rev 1.0 11/12/2002 09:18:06 PM JPMugaas
  13. { Initial check in. Import from FTP VC.
  14. }
  15. unit GMTToLocalDateTimeProc;
  16. interface
  17. uses
  18. IndyBox,
  19. Classes;
  20. type
  21. TGMTToLocalDateTimeBox = class(TIndyBox)
  22. public
  23. procedure Test; override;
  24. end;
  25. implementation
  26. uses
  27. INIFiles,
  28. IdCoreGlobal,
  29. IdGlobal,
  30. SysUtils;
  31. { TGMTToLocalDateTimeBox }
  32. procedure TGMTToLocalDateTimeBox.Test;
  33. var
  34. i: Integer;
  35. LDateTime: TDateTime;
  36. LMonth, LDay, LYear: Word;
  37. LTestString: string;
  38. LYMDCheck: string;
  39. begin
  40. with TStringList.Create do try
  41. LoadFromFile(GetDataDir + 'GMTToLocalDateTimeProc.dat');
  42. for i := 0 to Count - 1 do begin
  43. LYMDCheck := Strings[i];
  44. if Length(Trim(LYMDCheck)) > 0 then begin
  45. LTestString := Fetch(LYMDCheck, '=');
  46. LDateTime := GMTToLocalDateTime(LTestString);
  47. DecodeDate(LDateTime, LYear, LMonth, LDay);
  48. if Length(LYMDCheck) = 0 then begin
  49. Check((LYear >= 2000) and (LMonth in [8, 9, 10]), 'Date failed: ' + LTestString);
  50. end else begin
  51. Check(LYear = StrToInt(Copy(LYMDCheck, 1, 4)), 'Year mismatch: ' + LTestString);
  52. Check(LMonth = StrToInt(Copy(LYMDCheck, 5, 2)), 'Month mismatch: ' + LTestString);
  53. Check(LDay = StrToInt(Copy(LYMDCheck, 7, 2)), 'Day mismatch: ' + LTestString);
  54. end;
  55. end;
  56. end;
  57. finally Free; end;
  58. end;
  59. initialization
  60. TIndyBox.RegisterBox(TGMTToLocalDateTimeBox, 'GMTToLocalDateTimeProc', 'Misc');
  61. end.