home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drstp2tm -- Convert time stamp to time of day
- *
- * Synopsis ercode = drstp2tm(ftime,phour,pminute,psecond);
- *
- * int ercode Error code is -1 if time stamp
- * is not a legal time, 0 if o.k.
- * unsigned ftime 16-bit time stamp.
- * int *phour,*pminute,*psecond
- * Pointers to variables in which
- * the hour, minute, and second are
- * returned.
- *
- * Description This function converts a time of day from the DOS
- * directory time stamp format into separate hour, minute,
- * and second.
- *
- * The time stamp (ftime) 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 DRTM2STP to convert a time into this time stamp
- * format. Use DRDT2STP or DRSTP2DT to convert date
- * stamps.
- *
- * Returns ercode Returned error code (-1 if illegal time,
- * 0 if okay).
- * *phour,*pminute,*psecond
- * The time as numeric values.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bdirect.h>
- #include <butility.h>
-
- int drstp2tm(ftime,phour,pminute,psecond)
- unsigned ftime;
- int *phour,*pminute,*psecond;
- {
- *phour = ftime >> 11 ;
- *pminute = (ftime >> 5 ) & 0x3f ;
- *psecond = (ftime & 0x1f) << 1;
-
- if ( utrange(*phour, 0,23)
- || utrange(*pminute,0,59)
- || utrange(*psecond,0,59))
- return(-1); /* Time is out of range. */
-
- return 0; /* Success. */
- }