home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / croutes.zip / GETDATE.C < prev    next >
Text File  |  1984-05-17  |  2KB  |  51 lines

  1. /*                            *** getdate.c ***                      */
  2. /*                                                                   */
  3. /* IBM-PC microsoft "C" under PC-DOS                                 */
  4. /*                                                                   */
  5. /* Function to return a string containing the date in the format     */
  6. /* MM/DD/YY.                                                         */
  7. /*                                                                   */
  8. /* Written by L. Cuthbertson, May 1984                               */
  9. /*                                                                   */
  10. /*********************************************************************/
  11. /*                                                                   */
  12.  
  13. #define NULL    '\000'
  14. #define DELIM    '/'
  15.  
  16. int getdate(string)
  17. char string[];
  18. {
  19.     char month[3],day[3],year[5];
  20.     int imo,iday,iyr;
  21.     int i,j;
  22.  
  23.     /* call assembler routine to get date in integer format */
  24.     dosdate(&imo,&iday,&iyr);
  25.  
  26.     /* convert integers into strings */
  27.     sprintf(month,"%02d",imo);
  28.     sprintf(day,"%02d",iday);
  29.     sprintf(year,"%02d",iyr);
  30.  
  31.     /* build output string */
  32.     j = 0;
  33.     for(i=0;month[i] != NULL;i++)
  34.         string[j++] = month[i];
  35.  
  36.     string[j++] = DELIM;
  37.  
  38.     for(i=0;day[i] != NULL;i++)
  39.         string[j++] = day[i];
  40.  
  41.     string[j++] = DELIM;
  42.  
  43.     for(i=2;year[i] != NULL;i++)    /* skip century identifier */
  44.         string[j++] = year[i];
  45.  
  46.     string[j] = NULL;
  47.  
  48.     /* done */
  49.     return(0);
  50. }
  51.