home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drdt2stp -- Convert date to date stamp
- *
- * Synopsis ercode = drdt2stp(pfdate,year,month,day);
- *
- * int ercode Error code is -1 if day of year
- * is not a legal date, 0 if okay.
- * unsigned *pftime Pointer to resulting 16-bit date stamp.
- * int year Year (1980 to 2099)
- * int month Month (1 to 12)
- * int day Day of the month (1 to 31)
- *
- * Description This function converts a date into the DOS directory
- * date stamp format.
- *
- * The date stamp (*pfdate) 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 DRSTP2DT to split a date stamp into separate year,
- * month, and day values. Use DRDT2STP or DRSTP2DT to
- * convert date stamps.
- *
- * Returns ercode Returned error code (-1 if illegal date,
- * 0 if okay).
- * *pfdate Resulting 16-bit date stamp (0 if error).
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bdirect.h>
- #include <butility.h>
-
- int drdt2stp(pfdate,year,month,day)
- unsigned *pfdate;
- int year,month,day;
- {
- if ( utrange(year, 1980,2099)
- || utrange(month, 1, 12)
- || utrange(day, 1, 31))
- {
- *pfdate = 0;
- return(-1); /* Date is out of range. */
- }
- *pfdate = ((year - 1980) << 9) | (month << 5) | day;
- return 0;
- }