home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / SYSDATE0.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  1.0 KB  |  45 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;
  10. const
  11.    month : array [1..12] of string[3]
  12.            = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  13.               'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  14. var
  15.    reg:           registers;
  16.  
  17.    function strval (i: integer): string2;
  18.    begin
  19.       strval := chr(((i div 10) mod 10) + ord('0')) +
  20.                 chr((i mod 10) + ord('0'));
  21.    end;
  22.  
  23. begin
  24.    reg.ax := $2a00;
  25.    msdos(reg);
  26.    system_date := strval(lo(reg.dx)) + '-' +
  27.                   month[hi(reg.dx)] + '-' +
  28.                   strval(reg.cx-1900);
  29. end;
  30.  
  31.  
  32. function system_time: anystring;
  33. var
  34.    reg:       registers;
  35.    hh,mm,ss:  string[2];
  36.  
  37. begin
  38.    reg.ax := $2c00;
  39.    msdos(reg);
  40.    str(hi(reg.cx),hh);  if length(hh) = 1 then hh := '0' + hh;
  41.    str(lo(reg.cx),mm);  if length(mm) = 1 then mm := '0' + mm;
  42.    str(hi(reg.dx),ss);  if length(ss) = 1 then ss := '0' + ss;
  43.    system_time := hh + ':' + mm + ':' + ss;
  44. end;
  45.