home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / units / datebox.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  731 b   |  34 lines

  1. unit Datebox;
  2.  
  3. interface
  4.  
  5. const
  6.   Months: array[1..12] of string =
  7.     ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  8.      'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  9.  
  10. function FormatDate(Temp: string; DateType: Integer): string;
  11.  
  12. implementation
  13. uses
  14.   MathBox,
  15.   StrBox, SysUtils;
  16.  
  17. function FormatDate(Temp: string; DateType: Integer): string;
  18. var
  19.   Day, Month, MonthTemp, Year: string;
  20.   i: Integer;
  21. begin
  22.   Day := Shorten(Temp, 7);
  23.   MonthTemp[0] := #3;
  24.   Move(Temp[4], MonthTemp[1], 3);
  25.   for i := 1 to 12 do
  26.     if MonthTemp = Months[i] then
  27.       Month := Int2StrPad0(i, 2);
  28.   Year[0] := #2;
  29.   Move(Temp[8], Year[1], 2);
  30.   Result := Month + DateSeparator + Day + DateSeparator + Year;
  31. end;
  32.  
  33. end.
  34.