home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / UTTIM2TK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.2 KB  |  43 lines

  1. /**
  2. *
  3. * Name        UTTIM2TK -- Compute the IBM clock tick value for a
  4. *                given time of day.
  5. *
  6. * Synopsis    ticks = uttim2tk (hrs, mins, secs, hunds);
  7. *
  8. *        unsigned long ticks    The tick value that corresponds
  9. *                    to the given time of day.
  10. *        int hrs, mins,        Time of day to compute tick
  11. *            secs, hunds     value for.
  12. *
  13. * Description    UTTIM2TK computes the number of timer ticks that will be
  14. *        generated in an IBM personal computer (or compatible) in
  15. *        the amount of time specified.
  16. *
  17. *        The tick value generated is within 2 ticks of the
  18. *        correct value, as long as the time passed to UTTIM2TK is
  19. *        a normal time.
  20. *
  21. *        On standard IBM PCs, timer ticks occur 1193180/65536
  22. *        (about 18.2) times per second.
  23. *
  24. * Returns    ticks        The number of timer ticks represented
  25. *                by the given time.
  26. *
  27. * Version    6.00 (C)Copyright Blaise Computing Inc.  1987,1989
  28. *
  29. **/
  30.  
  31. #include <butil.h>
  32.  
  33. #define UL (unsigned long)
  34.  
  35. unsigned long uttim2tk (hrs, mins, secs, hunds)
  36. int hrs, mins, secs, hunds;
  37. {
  38.     return   (hrs  ? ((UL hrs * 65543L) + UL  (hrs  / 3)      ) : 0L)
  39.        + (mins ? ((UL mins * 1092L) + UL ((mins << 1) / 5)) : 0L)
  40.        + (secs ? ((UL secs * 18L)    + UL  (secs / 5)      ) : 0L)
  41.        + (UL hunds / 5L);
  42. }
  43.