home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name UTTK2TIM -- Compute the time of day for a given IBM
- * clock tick value.
- *
- * Synopsis uttk2tim (ticks, phrs, pmins, psecs, phunds);
- *
- * unsigned long ticks Tick value for which to
- * compute a time of day.
- * int *phrs, *pmins, Returned time of day.
- * *psecs, *phunds
- *
- * Description UTTK2TIM computes the time of day which corresponds to
- * the IBM clock tick value given.
- *
- * The time value generated is within 1.4 seconds of the
- * correct value, as long as the number of ticks passed to
- * UTTK2TIM is between 0 and 1,573,066 (the number of ticks
- * in one day).
- *
- * On standard IBM PCs, timer ticks occur 1193180/65536
- * (about 18.2) times per second.
- *
- * Returns None.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
- #include <butil.h>
-
- #define UL (unsigned long)
-
- void uttk2tim (ticks, phrs, pmins, psecs, phunds)
- unsigned long ticks;
- int *phrs, *pmins, *psecs, *phunds;
- {
- unsigned long fudge;
-
- *phrs = (int) (ticks / 65543L);
- fudge = (*phrs)
- ? ((UL (*phrs) * 33494L) / 100000L)
- : (0L);
- ticks -= UL (*phrs) * 65543L;
- ticks = (ticks > fudge) ? (ticks - fudge) : (0L);
-
- *pmins = (int) (ticks / 1092L);
- fudge = (*pmins)
- ? ((UL (*pmins) * 388915L) / 1000000L)
- : (0L);
- ticks -= UL (*pmins) * 1092L;
- ticks = (ticks > fudge) ? (ticks - fudge) : (0L);
-
- *psecs = (int) (ticks / 18L);
- fudge = (*psecs)
- ? ((UL (*psecs) * 206482L) / 1000000L)
- : (0L);
- ticks -= UL (*psecs) * 18L;
- ticks = (ticks > fudge) ? (ticks - fudge) : (0L);
-
- *phunds = (int) (ticks * 4L);
- }