home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drtm2stp -- Convert time of day to time stamp
- *
- * Synopsis ercode = drtm2stp(pftime,hour,minute,second);
- *
- * int ercode Error code is -1 if time of day
- * is not a legal time, 0 if okay.
- * unsigned *pftime Pointer to resulting 16-bit time stamp.
- * int hour Hour of the day (0-23)
- * int minute Minute of the hour (0-59)
- * int second Second of the minute (0-59)
- *
- * Description This function converts a time of day into the DOS
- * directory time stamp format.
- *
- * The time stamp (*pftime) is a time of day packed into
- * the following format:
- *
- * ********** bits ***********
- * 1 1 1 1 1 1
- * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- *
- * h h h h h m m m m m m s s s s s = ftime
- *
- * where the second bits represent two-second increments.
- * This is the same format used by DRRETSTP, DRSETSTP,
- * DRSFIRST, and DRSNEXT.
- *
- * Use DRSTP2TM to split a time stamp into separate hour,
- * minute, and second values. Use DRDT2STP or DRSTP2DT to
- * convert date stamps.
- *
- * Returns ercode Returned error code (-1 if illegal time,
- * 0 if okay).
- * *pftime Resulting 16-bit time stamp (0 if error).
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bdirect.h>
- #include <butility.h>
-
- int drtm2stp(pftime,hour,minute,second)
- unsigned *pftime;
- int hour,minute,second;
- {
- if ( utrange(hour, 0,23)
- || utrange(minute,0,59)
- || utrange(second,0,59))
- {
- *pftime = 0;
- return(-1); /* Time is out of range. */
- }
- *pftime = (hour << 11) | (minute << 5) | (second >> 1);
- return 0;
- }