home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / TP-UTIL.ARK / MARKTIME.SRC < prev    next >
Text File  |  1986-01-06  |  2KB  |  63 lines

  1. {->>>>MarkTime<<<<---------------------------------------------}
  2. {                                                              }
  3. { Filename: MARKTIME.SRC -- Last Modified 10/26/85             }
  4. {                                                              }
  5. { This routine returns in TimeRec Delta the time difference    }
  6. { between the time passed to it in Mark and the current time.  }
  7. { It requires a prior definition of type TimeRec:              }
  8. {                                                              }
  9. {     TimeRec = Record                                         }
  10. {                 TimeComp   : Integer;                        }
  11. {                 TimeString : String80;                       }
  12. {                 Hours,Minutes,Seconds,Hundredths : Integer   }
  13. {               END;                                           }
  14. {                                                              }
  15. { NOTE:  This routine will not operate correctly for intervals }
  16. {        longer than 24 hours!                                 }
  17. {--------------------------------------------------------------}
  18.  
  19. PROCEDURE MarkTime(Var Mark,Delta : TimeRec);
  20.  
  21. TYPE
  22.   Reg     = RECORD
  23.               CASE Boolean OF
  24.                 False : (Word : Integer);
  25.                 True  : (LoByte,HiByte : Byte)
  26.             END;
  27.  
  28.   Regpack = RECORD
  29.               AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Reg
  30.             END;
  31.  
  32. VAR
  33.   TempTime : TimeRec;
  34.   TempSeconds,DeltaSeconds : Real;
  35.  
  36. FUNCTION TimeToSeconds(T : TimeRec) : Real;
  37.  
  38. BEGIN
  39.   WITH T DO TimeToSeconds := (Hours * 3600) + (Minutes * 60) +
  40.     Seconds + (Hundredths * 0.01);
  41. END;
  42.  
  43. BEGIN
  44.   GetTime(TempTime);
  45.   IF TempTime.TimeComp < Mark.TimeComp THEN
  46.     BEGIN
  47.       TempSeconds := TimeToSeconds(Mark) + 86400.0;
  48.       DeltaSeconds := TimeToSeconds(TempTime) - TempSeconds
  49.     END
  50.   ELSE
  51.     DeltaSeconds := TimeToSeconds(TempTime)-TimeToSeconds(Mark);
  52.   WITH Delta DO
  53.     BEGIN
  54.       Hundredths := Trunc(Frac(DeltaSeconds) * 100);
  55.       DeltaSeconds := Int(DeltaSeconds);
  56.       TempSeconds :=  Int(DeltaSeconds / 3600.0);
  57.       Hours := Trunc(TempSeconds);
  58.       DeltaSeconds := DeltaSeconds - (Hours * 3600.0);
  59.       Minutes := Trunc(DeltaSeconds / 60);
  60.       Seconds := Trunc(DeltaSeconds - (Minutes * 60.0));
  61.     END
  62. END;
  63. Q°⌡╡ ª╪NñÉÄ╣▀╩Y╪∞Iû₧4]╥Ö─½@$ ╧"▌└i╪█ÿåF∙╕X╧J│╒n╦/Ö─x┐Ä├╫╧òÿÉ╪εIsaÇ╤└°±╡AH∩°▓DDß9─1╖-╥æk/J╣Y