home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drstp2dt -- Convert date stamp to date
- *
- * Synopsis ercode = drstp2dt(fdate,pyear,pmonth,pday);
- *
- * int ercode Error code is -1 if date stamp
- * is not a legal date, 0 if o.k.
- * unsigned fdate 16-bit date stamp.
- * int *pyear,*pmonth,*pday Pointers to variables in which
- * the year, month, and day are returned.
- *
- * Description This function converts a calendar date from the DOS
- * directory date stamp format into separate year, month,
- * and day.
- *
- * The date stamp (fdate) is a date of the year 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
- *
- * y y y y y y y m m m m d d d d d = fdate
- *
- * where the year bits represent 0 - 119 (1980 to 2099).
- * This is the same format used by DRRETSTP, DRSETSTP,
- * DRSFIRST, and DRSNEXT.
- *
- * Use DRDT2STP to convert a date into this date stamp
- * format. Use DRTM2STP or DRSTP2TM to convert time
- * stamps.
- *
- * Returns ercode Returned error code
- * *pyear,*pmonth,*pday The date as numeric values.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bdirect.h>
- #include <butility.h>
-
- int drstp2dt(fdate,pyear,pmonth,pday)
- unsigned fdate;
- int *pyear,*pmonth,*pday;
- {
- *pyear = (fdate >> 9) + 1980;
- *pmonth = (fdate >> 5) & 0x0f;
- *pday = fdate & 0x1f;
-
- if ( utrange(*pyear,1900,2099)
- || utrange(*pmonth,1,12)
- || utrange(*pday,1,31))
- return(-1); /* Date is out of range. */
-
- return 0; /* Success. */
- }