home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1989 / 12 / algorith / timedate.inc < prev   
Encoding:
Text File  |  1989-08-29  |  1.6 KB  |  70 lines

  1.  
  2. type hstring=string[4];
  3.  
  4. function zwei(str:hstring):hstring;
  5. begin
  6.   zwei:=copy('0'+str,length(str),2);
  7. end;
  8.  
  9. type
  10.   TimeString = string[8];
  11.  
  12. function time: TimeString;
  13. (* Für Turbo 3.0 Kommentarklammern entfernen
  14. type Registers = record
  15.                    case integer of
  16.                      1 : (ax,bx,cx,dx,bp,si,di,ds,es,flags: word);
  17.                      2 : (al,ah,bl,bh,cl,ch,dl,dh : BYTE);
  18.                    end;
  19. *)
  20.  
  21. var
  22.   recpack:          Registers;             {assign record}
  23.   ah,al,ch,cl,dh:   byte;
  24.   hour,min,sec:     string[2];
  25.  
  26. begin
  27.   recpack.ah := $2c;                             {initialize correct registers}
  28.   intr($21,recpack);                     {call interrupt}
  29.   with recpack do
  30.   begin
  31.     str(ch,hour);
  32.     hour:=zwei(hour);                  {convert to string}
  33.     str(cl,min);
  34.     min:=zwei(min);                       { " }
  35.     str(dh,sec);
  36.     sec:=zwei(sec);                         { " }
  37.   end;
  38.   time := hour+':'+min+':'+sec;
  39. end;
  40.  
  41. type
  42.   DateStr = string[10];
  43.  
  44. function Date: DateStr;
  45.  
  46. var
  47.   recpack:       Registers;                {record for MsDos call}
  48. month,day:     string[2];
  49.   year:          string[4];
  50.   dx,cx:         integer;
  51.  
  52. begin
  53.   with recpack do
  54.   begin
  55.     ax := $2a shl 8;
  56.   end;
  57.   MsDos(recpack);                        { call function }
  58.   with recpack do
  59.   begin
  60.     str(cx,year);                       {convert to string}
  61.     str(dx mod 256,day);
  62.     day:=zwei(day);                     { " }
  63.     str(dx shr 8,month);
  64.     month:=zwei(month);                     { " }
  65.   end;
  66.   date := day+'.'+month+'.'+year;
  67. end;
  68.  
  69.  
  70.