home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s3.arc / PIBTIMRH.MOD < prev    next >
Text File  |  1987-12-17  |  7KB  |  124 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*      TimeOfDayH  --- Get time of day in 1/100 seconds from midnight      *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. FUNCTION TimeOfDayH : LONGINT;
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*     Function:  TimeOfDayH                                                *)
  10. (*                                                                          *)
  11. (*     Purpose:   Gets time of day from internal clock in 1/100 seconds     *)
  12. (*                                                                          *)
  13. (*     Calling sequence:                                                    *)
  14. (*                                                                          *)
  15. (*        Tod := TimeOfDayH : LONGINT;                                      *)
  16. (*                                                                          *)
  17. (*           Tod --- Real number which is timer value expressed in          *)
  18. (*                   hundredths of seconds as:                              *)
  19. (*                   ( 360000 x hour + 6000 x minutes + 100 x seconds +     *)
  20. (*                     hundredths of seconds ).                             *)
  21. (*                                                                          *)
  22. (*     Calls:  GetTime                                                      *)
  23. (*                                                                          *)
  24. (*--------------------------------------------------------------------------*)
  25.  
  26. VAR
  27.    Hours   : WORD;
  28.    Minutes : WORD;
  29.    Seconds : WORD;
  30.    SecHun  : WORD;
  31.  
  32.    TimerVal: LONGINT;
  33.  
  34. BEGIN (* TimeOfDayH *)
  35.  
  36.    GetTime( Hours, Minutes, Seconds, SecHun );
  37.  
  38.    TimerVal    := Hours;
  39.    TimeOfDayH  := TimerVal * 360000 + Minutes * 6000 + Seconds * 100 + SecHun;
  40.  
  41. END   (* TimeOfDayH *);
  42.  
  43. (*--------------------------------------------------------------------------*)
  44. (*       TimeDiffH  --- Get difference in time between two timer values     *)
  45. (*--------------------------------------------------------------------------*)
  46.  
  47. FUNCTION TimeDiffH( Timer1, Timer2: LONGINT ) : LONGINT;
  48.  
  49. (*--------------------------------------------------------------------------*)
  50. (*                                                                          *)
  51. (*     Function:  TimeDiffH                                                 *)
  52. (*                                                                          *)
  53. (*     Purpose:   Get difference in time between two timer values           *)
  54. (*                in hundredths of seconds.                                 *)
  55. (*                                                                          *)
  56. (*     Calling sequence:                                                    *)
  57. (*                                                                          *)
  58. (*        Tdiff := TimeDiffH( Timer1, Timer2: LONGINT ) : REAL;             *)
  59. (*                                                                          *)
  60. (*           Timer1  --- first timer value (earlier)                        *)
  61. (*           Timer2  --- second timer value (later)                         *)
  62. (*                                                                          *)
  63. (*           Tdiff   --- difference between timer values                    *)
  64. (*                                                                          *)
  65. (*     Calls:  None                                                         *)
  66. (*                                                                          *)
  67. (*     Remarks:                                                             *)
  68. (*                                                                          *)
  69. (*        This routine will handle time wrap around midnight.  However, it  *)
  70. (*        only handles timer values <= 24 hours in duration.                *)
  71. (*                                                                          *)
  72. (*--------------------------------------------------------------------------*)
  73.  
  74. CONST
  75.    Hundredths_Secs_Per_Day = 8640000    (* 1/100 Seconds in one day *);
  76.  
  77. VAR
  78.    TDiff : LONGINT;
  79.  
  80. BEGIN (* TimeDiffH *)
  81.  
  82.    TDiff := Timer2 - Timer1;
  83.  
  84.    IF Tdiff < 0 THEN Tdiff := Tdiff + Hundredths_Secs_Per_Day;
  85.  
  86.    TimeDiffH := Tdiff;
  87.  
  88. END   (* TimeDiffH *);
  89.  
  90. (*--------------------------------------------------------------------------*)
  91. (*      TimeStringH  --- convert timer value in 1/100 secs to string        *)
  92. (*--------------------------------------------------------------------------*)
  93.  
  94. FUNCTION TimeStringH( Timer_Value  : LONGINT;
  95.                       Timer_Format : Time_Format_Type ) : ShortStr;
  96.  
  97. (*--------------------------------------------------------------------------*)
  98. (*                                                                          *)
  99. (*     Function:  TimeStringH                                               *)
  100. (*                                                                          *)
  101. (*     Purpose:   Convert elapsed timer value to HH:MM:SS string            *)
  102. (*                                                                          *)
  103. (*     Calling sequence:                                                    *)
  104. (*                                                                          *)
  105. (*        Tstring := TimeStringH( Timer_Value  : LONGINT;                   *)
  106. (*                                Timer_Format : Time_Format_Type ) :       *)
  107. (*                                AnyStr;                                   *)
  108. (*                                                                          *)
  109. (*           Timer_Value ---  Real number which is timer value expressed as *)
  110. (*                            1/100th seconds from 12 am.                   *)
  111. (*           Timer_Format --- Format type for time                          *)
  112. (*           Tstring      --- Resultant 'HH:MM:SS' form of time             *)
  113. (*                                                                          *)
  114. (*     Calls:  None                                                         *)
  115. (*                                                                          *)
  116. (*--------------------------------------------------------------------------*)
  117.  
  118. BEGIN (* TimeStringH *)
  119.  
  120.    TimeStringH := TimeString( Timer_Value DIV 100 , Timer_Format );
  121.  
  122. END   (* TimeStringH *);
  123.  
  124.