home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / DRSTP2TM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.7 KB  |  63 lines

  1. /**
  2. *
  3. * Name        drstp2tm -- Convert time stamp to time of day
  4. *
  5. * Synopsis    ercode = drstp2tm(ftime,phour,pminute,psecond);
  6. *
  7. *        int ercode      Error code is -1 if time stamp
  8. *                  is not a legal time, 0 if o.k.
  9. *        unsigned ftime      16-bit time stamp.
  10. *        int *phour,*pminute,*psecond
  11. *                  Pointers to variables in which
  12. *                  the hour, minute, and second are
  13. *                  returned.
  14. *
  15. * Description    This function converts a time of day from the DOS
  16. *        directory time stamp format into separate hour, minute,
  17. *        and second.
  18. *
  19. *        The time stamp (ftime) is a time of day packed into
  20. *        the following format:
  21. *
  22. *              **********   bits   ***********
  23. *              1 1 1 1 1 1
  24. *              5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  25. *
  26. *              h h h h h m m m m m m s s s s s    = ftime
  27. *
  28. *        where the second bits represent two-second increments.
  29. *        This is the same format used by DRRETSTP, DRSETSTP,
  30. *        DRSFIRST, and DRSNEXT.
  31. *
  32. *        Use DRTM2STP to convert a time into this time stamp
  33. *        format.  Use DRDT2STP or DRSTP2DT to convert date
  34. *        stamps.
  35. *
  36. * Returns    ercode          Returned error code (-1 if illegal time,
  37. *                  0 if okay).
  38. *        *phour,*pminute,*psecond
  39. *                  The time as numeric values.
  40. *
  41. * Version    3.0 (C)Copyright Blaise Computing Inc. 1986
  42. *
  43. **/
  44.  
  45. #include <bdirect.h>
  46. #include <butility.h>
  47.  
  48. int drstp2tm(ftime,phour,pminute,psecond)
  49. unsigned ftime;
  50. int     *phour,*pminute,*psecond;
  51. {
  52.     *phour   =    ftime >> 11         ;
  53.     *pminute = (ftime >> 5 ) & 0x3f     ;
  54.     *psecond = (ftime         & 0x1f) << 1;
  55.  
  56.     if (   utrange(*phour,  0,23)
  57.     || utrange(*pminute,0,59)
  58.     || utrange(*psecond,0,59))
  59.     return(-1);              /* Time is out of range.          */
  60.  
  61.     return 0;                  /* Success.              */
  62. }
  63.