home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL5.ZIP / SYSDATE.INC < prev    next >
Encoding:
Text File  |  1987-04-11  |  1.1 KB  |  47 lines

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