home *** CD-ROM | disk | FTP | other *** search
- Unit Timer2;
- {
- Author : Michael Warot
- Date : December, 1987
- Purpose : Provide timing functions.
- Notes : Does not provide midnight protection.
- }
- Interface
- Uses
- DOS;
-
- Procedure StartTime(Var X : LongInt);
- { Resets the tick counter }
-
- Function DT(X : LongInt) : LongInt;
- { Returns the time since the last Starttime, in seconds }
-
- Function TimeStamp : String;
- { Returns YYMMDD:HHMMSS }
-
- Implementation
-
- Var
- BiosTick : LongInt ABSOLUTE $40:$6c;
- LastTime : LongInt;
-
- Procedure Disable_Ints; Inline($FA);
- Procedure Enable_Ints; Inline($FB);
-
- Function Ticks : LongInt;
- Begin
- Disable_Ints;
- Ticks := BiosTick;
- Enable_Ints;
- End;
-
- Procedure StartTime(Var X : LongInt);
- Begin
- X := Ticks;
- End;
-
- Function DT(X : LongInt) : LongInt;
- Var
- Now : LongInt;
- Begin
- Now := Ticks;
- DT := Now - X;
- End;
-
- Function TimeStamp:String;
- Var
- Year,Month,Date,Day,
- Hour,Min,Sec,Sec100 : Word;
- Tmp,Tmp2 : String;
- I : Byte;
- Begin
- GetDate(Year,Month,Date,Day);
- GetTime(Hour,Min,Sec,Sec100);
- Year := Year MOD 100;
-
- Str(Year:2 ,Tmp2); Tmp := Tmp2;
- Str(Month:2 ,Tmp2); Tmp := Tmp + Tmp2;
- Str(Date:2 ,Tmp2); Tmp := Tmp + Tmp2 + ':';
- Str(Hour:2 ,Tmp2); Tmp := Tmp + Tmp2;
- Str(Min:2 ,Tmp2); Tmp := Tmp + Tmp2;
- Str(Sec:2 ,Tmp2); Tmp := Tmp + Tmp2;
- For i := 1 to Length(Tmp) DO
- If Tmp[i] = ' ' Then
- Tmp[i] := '0';
- TimeStamp := Tmp;
- End; { TimeStamp }
-
-
- End.