home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 463.lha / Date_routines / packdate.c < prev    next >
Text File  |  1991-01-04  |  744b  |  32 lines

  1. /*****
  2.                               packdate()
  3.  
  4.       This function collapses the date into an unsigned integer using the
  5.    DOS disk format: 0x00 - 0x04 = day, 0x05 - 0x08 = month, 0x09 - 0x0f =
  6.    year. The year is formed relative to 1980.
  7.  
  8.    Argument list:    int day        the day
  9.                      int month      the month
  10.                      int year       the year
  11.  
  12.    Return value:     unsigned int
  13.  
  14. *****/
  15.  
  16. unsigned int packdate(int day, int month, int year)
  17. {
  18.    unsigned result = 0;
  19.  
  20.    result = day;
  21.    month <<= 0x05;
  22.    if (year < 100)              /* No century given? */
  23.       year -= 80;
  24.    else
  25.       if (year >= 1980)
  26.          year -= 1980;
  27.    year <<= 0x09;
  28.    result += month;
  29.    result += year;
  30.    return result;
  31. }
  32.