home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PROLST.ZIP / FDTTM.INC next >
Encoding:
Text File  |  1986-11-05  |  1.9 KB  |  77 lines

  1. {BEGINNING OF FDTTM.INC}
  2. (* Functions to return strings of FileCreationDate and FileCreationTime
  3.    of an open file.  Must be called with a valid file handle *)
  4. type
  5.   String16  =      String[16];
  6.  
  7. Function FDate(var f): string16;
  8.  
  9. var
  10.   handle: Integer absolute f; {File handle is the first word of a file's FIB}
  11.   regs: record
  12.         case integer of
  13.             1: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Integer);
  14.             2: (AL, AH, BL, BH, CL, CH, DL, DH: Byte)
  15.         end;
  16.   date: integer;
  17.   year,month,day : string16;
  18.  
  19. begin
  20.   regs.AX := $5700;             {DOS function to get file date from handle}
  21.   regs.BX := handle;
  22.   MsDos(regs);
  23.   if ( (regs.flags and $0001) <> 0) then  { not a valid handle}
  24.       begin                               { return a null string}
  25.       Fdate :='';
  26.       exit;
  27.       end;
  28.   date := regs.DX;
  29.  
  30.   Str((Hi(Date) shr 1)+80, Year);
  31.   Str(((Date shr 5) and 15):2, Month);
  32.   Str((Date and 31):2, Day);
  33.   If    Day[1] = ' '
  34.   Then  Day[1] := '0';
  35.  
  36.   FDate := Month + '-' + Day + '-' + Year;
  37.  
  38. end; {FDate}
  39.  
  40.  
  41. Function FTime(var f): string16;
  42.  
  43. var
  44.   handle: Integer absolute f; {File handle is the first word of a file's FIB}
  45.   regs: record
  46.           case Integer of
  47.             1: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Integer);
  48.             2: (AL, AH, BL, BH, CL, CH, DL, DH: Byte)
  49.         end;
  50.  
  51.   Time, Hour, Minute:         Integer;
  52.   Hr,Min: String16;
  53.  
  54. Begin
  55.  
  56.   regs.AX := $5700;             {DOS function to get file time from handle}
  57.   regs.BX := handle;
  58.   MsDos(regs);
  59.   if ( (regs.flags and $0001) <> 0) then  { not a valid handle}
  60.       begin                               { return a null string}
  61.       FTime :='';
  62.       exit;
  63.       end;
  64.   Time := regs.CX;
  65.   Hour := Hi(Time) shr 3;
  66.   Minute := (Time shr 5) and 63;
  67.  
  68.   Str(Hour:2, Hr);
  69.   Str(Minute:2, Min);
  70.   If   Min[1] = ' '
  71.   Then Min[1] := '0';
  72.  
  73.   FTime := Hr + ':' + Min ;
  74.  
  75. end; {FTime}
  76. {END OF FDTTM.INC}
  77.