home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / date / stamp_dt / stamp.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1988-08-23  |  1.9 KB  |  76 lines

  1. Program Stamp;
  2.  
  3. {
  4.  By Timothy B. Coleman.  Rather than using Turbo Pascal Ver. 4 Date and time
  5.  Procedures, I have called MSDOS Int 21H date and time. Notice this source
  6.  is larger than the source for DT.PAS, which uses Turbo Pascal Ver. 4 Date
  7.  and Time functions to accomplish the same thing.  The .EXE file produced is
  8.  slightly smaller that the version produced with TP4 functions.
  9.  }
  10.  
  11. Uses DOS;
  12.  
  13. Var
  14.       ThisDate        : String[15];
  15.       Time       : String[15];
  16.       Regs       : Registers;
  17.  
  18. PROCEDURE GetDate;
  19.  
  20. Type
  21.   String9 = String[9];
  22.  
  23. Const
  24.   MonthNames : array [1..12] of String9 =
  25.   ('January','February','March','April','May','June',
  26.    'July','August','September','October','November','December');
  27.  
  28. VAR
  29. Year,Month,Day : Integer;
  30. Temp1, DateString, Temp2 : String[16];
  31. Begin
  32.       regs.ax := $2a00;
  33.       msdos(regs);
  34.       Year := regs.cx;
  35.       Month := hi(regs.dx);
  36.       Day := lo(regs.dx);
  37.       Str(Year,Temp1);
  38.       DateString :=  MonthNames[Month];
  39.       Str(Day,Temp2);
  40.       DateString := DateString  + ' ' + Temp2 + ', ' + Temp1;
  41.       ThisDate := Datestring;
  42. end;
  43.  
  44. Procedure GetTime;
  45.  
  46. Var
  47. TimeString  :  String[16];
  48. TempTime    :  String[5];
  49. Hours, Minutes, Seconds : Integer;
  50.  
  51. Begin
  52.   regs.ax := $2C00;
  53.   MsDos(regs);
  54.   Hours := hi(regs.cx);
  55.   Str(Hours,TempTime);
  56.   If length(TempTime) = 1 Then TempTime := '0' + TempTime;
  57.   TimeString := TempTime + ':';
  58.   Minutes := lo(regs.cx);
  59.   Str(Minutes,TempTime);
  60.   If length(TempTime) = 1 Then TempTime := '0' + TempTime;
  61.   TimeString := TimeString + TempTime + ':';
  62.   Seconds := hi(regs.dx);
  63.   Str(Seconds,TempTime);
  64.   If length(TempTime) = 1 Then TempTime := '0' + TempTime;
  65.   TimeString := Timestring + Temptime;
  66.   Time := TimeString;
  67. end;   { GetTime }
  68.  
  69. Begin         {main}
  70.   GetDate;
  71.   GetTime;
  72.   Writeln('Date and Time:  ',ThisDate,'   ',Time); {No Direct video so
  73.   redirectable to a file or printer, serial or par.}
  74.  
  75. end.
  76.