home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / EZY110-1.ARJ / STRUCT.ARJ / CLIB.ARJ / DATE4.CPP < prev    next >
C/C++ Source or Header  |  1995-03-28  |  853b  |  28 lines

  1. #include <ezycom.h>
  2. #include <ezylib.h>
  3.  
  4. /**********************************************************
  5.  * Convert a Date and Time to a Long (DOS Packed DateTime)
  6.  *
  7.  * Returns the converted date on success or 0 on failure.
  8.  *
  9.  * eg: longdate = date2word(1992,1,1,12,53,50);
  10.  **********************************************************/
  11. unsigned long Date2Long(word year, word month, word day,
  12.                         word hour, word min,   word sec)
  13. {
  14.     unsigned long  todatefield,totimefield;
  15.  
  16.     if (!CheckDate(year,month,day) || year < 1980 || year > 2107) return(0);
  17.  
  18.     todatefield = day;
  19.      todatefield = todatefield + ((month) << 5);
  20.      todatefield = todatefield + ((year-1980) << 9);
  21.  
  22.      totimefield = (sec >> 1) + (min << 5) + (hour << 12);
  23.  
  24.      totimefield = totimefield + (todatefield << 16);
  25.  
  26.      return(totimefield);
  27. }
  28.