home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / SYSDATE.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  942 b   |  41 lines

  1.  
  2. (*
  3.  * sysdate - library to return system date and time
  4.  *
  5.  * s.h.smith, 10-sep-86
  6.  *
  7.  *)
  8.  
  9. function system_date: anystring;   {format: yy/mm/dd}
  10. var
  11.    reg:           registers;
  12.  
  13.    function strval (i: integer): string2;
  14.    begin
  15.       strval := chr(((i div 10) mod 10) + ord('0')) +
  16.                 chr((i mod 10) + ord('0'));
  17.    end;
  18.  
  19. begin
  20.    reg.ax := $2a00;
  21.    msdos(reg);
  22.    system_date := strval(reg.cx-1900) + '/' +
  23.                   strval(hi(reg.dx)) + '/' +
  24.                   strval(lo(reg.dx));
  25. end;
  26.  
  27.  
  28. function system_time: anystring;   {format: hh:mm:ss}
  29. var
  30.    reg:       registers;
  31.    hh,mm,ss:  string[2];
  32.  
  33. begin
  34.    reg.ax := $2c00;
  35.    msdos(reg);
  36.    str(hi(reg.cx),hh);  if length(hh) = 1 then hh := '0' + hh;
  37.    str(lo(reg.cx),mm);  if length(mm) = 1 then mm := '0' + mm;
  38.    str(hi(reg.dx),ss);  if length(ss) = 1 then ss := '0' + ss;
  39.    system_time := hh + ':' + mm + ':' + ss;
  40. end;
  41.