home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / LPT_PAS.ZIP / TIMER2.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-08-09  |  1.4 KB  |  74 lines

  1. Unit Timer2;
  2. {
  3.   Author  : Michael Warot
  4.   Date    : December, 1987
  5.   Purpose : Provide timing functions.
  6.   Notes   : Does not provide midnight protection.
  7. }
  8. Interface
  9. Uses
  10.   DOS;
  11.  
  12. Procedure StartTime(Var X : LongInt);
  13. { Resets the tick counter }
  14.  
  15. Function DT(X : LongInt) : LongInt;
  16. { Returns the time since the last Starttime, in seconds }
  17.  
  18. Function TimeStamp : String;
  19. { Returns YYMMDD:HHMMSS }
  20.  
  21. Implementation
  22.  
  23. Var
  24.   BiosTick : LongInt ABSOLUTE $40:$6c;
  25.   LastTime : LongInt;
  26.  
  27. Procedure Disable_Ints; Inline($FA);
  28. Procedure Enable_Ints;  Inline($FB);
  29.  
  30. Function Ticks : LongInt;
  31. Begin
  32.   Disable_Ints;
  33.   Ticks := BiosTick;
  34.   Enable_Ints;
  35. End;
  36.  
  37. Procedure StartTime(Var X : LongInt);
  38. Begin
  39.   X := Ticks;
  40. End;
  41.  
  42. Function DT(X : LongInt) : LongInt;
  43. Var
  44.   Now : LongInt;
  45. Begin
  46.   Now := Ticks;
  47.   DT := Now - X;
  48. End;
  49.  
  50. Function TimeStamp:String;
  51. Var
  52.   Year,Month,Date,Day,
  53.   Hour,Min,Sec,Sec100   : Word;
  54.   Tmp,Tmp2 : String;
  55.   I        : Byte;
  56. Begin
  57.   GetDate(Year,Month,Date,Day);
  58.   GetTime(Hour,Min,Sec,Sec100);
  59.   Year := Year MOD 100;
  60.  
  61.   Str(Year:2  ,Tmp2); Tmp := Tmp2;
  62.   Str(Month:2 ,Tmp2); Tmp := Tmp + Tmp2;
  63.   Str(Date:2  ,Tmp2); Tmp := Tmp + Tmp2 + ':';
  64.   Str(Hour:2  ,Tmp2); Tmp := Tmp + Tmp2;
  65.   Str(Min:2   ,Tmp2); Tmp := Tmp + Tmp2;
  66.   Str(Sec:2   ,Tmp2); Tmp := Tmp + Tmp2;
  67.   For i := 1 to Length(Tmp) DO
  68.     If Tmp[i] = ' ' Then
  69.       Tmp[i] := '0';
  70.   TimeStamp := Tmp;
  71. End; { TimeStamp }
  72.  
  73.  
  74. End.