home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL5.ZIP / SYSDATE0.INC < prev    next >
Encoding:
Text File  |  1987-03-14  |  1.2 KB  |  50 lines

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