home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / JDTPPROG.ZIP / MARKTIME.SRC < prev    next >
Encoding:
Text File  |  1985-08-18  |  1.8 KB  |  55 lines

  1. {->>>>MarkTime<<<<---------------------------------------------}
  2. { This routine returns in TimeRec Delta the time difference    }
  3. { between the time passed to it in Mark and the current time.  }
  4. { It requires a prior definition of type TimeRec:              }
  5. {                                                              }
  6. {     TimeRec = Record                                         }
  7. {                 DayOfWeek,                                   }
  8. {                 Hours,Minutes,Seconds,Hundredths : Integer   }
  9. {               End;                                           }
  10. {--------------------------------------------------------------}
  11.  
  12. Procedure MarkTime(Var Mark,Delta : TimeRec);
  13.  
  14. Type Reg     = Record
  15.                  Case Boolean of
  16.                    True : (Word : Integer);
  17.                    False: (LoByte : Byte;
  18.                            HiByte : Byte)
  19.                End;
  20.  
  21.      RegPack = Record
  22.                  AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : Reg
  23.                End;
  24.  
  25.  
  26. Var TempTime : TimeRec;
  27.     TempSeconds,DeltaSeconds : Real;
  28.  
  29. Function TimeToSeconds(T : TimeRec) : Real;
  30.  
  31. Begin
  32.   With T Do TimeToSeconds := (Hours * 3600) + (Minutes * 60) +
  33.     Seconds + (Hundredths * 0.01);
  34. End;
  35.  
  36. Begin
  37.   GetTime(TempTime);
  38.   If TempTime.DayOfWeek = Mark.DayOfWeek then
  39.     DeltaSeconds := TimeToSeconds(TempTime)-TimeToSeconds(Mark)
  40.   Else
  41.     Begin
  42.       TempSeconds := TimeToSeconds(Mark) + 86400.0;
  43.       DeltaSeconds := TimeToSeconds(TempTime) - TempSeconds
  44.     End;
  45.   With Delta Do
  46.     Begin
  47.       Hundredths := Trunc(Frac(DeltaSeconds) * 100);
  48.       DeltaSeconds := Int(DeltaSeconds);
  49.       Hours :=  Trunc(DeltaSeconds / 3600.0);
  50.       DeltaSeconds := DeltaSeconds - (Hours * 3600.0);
  51.       Minutes := Trunc(DeltaSeconds / 60);
  52.       Seconds := Trunc(DeltaSeconds - (Minutes * 60.0));
  53.     End
  54. End;
  55.