home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 463.lha / Date_routines / makedate.c < prev    next >
C/C++ Source or Header  |  1991-01-04  |  1KB  |  43 lines

  1. /*****
  2.                               makedate()
  3.  
  4.       This function formats the system date into the string passed to the
  5.    function using interrupt 0x21.
  6.  
  7.    Argument list:    char *buff     pointer to a character array for the
  8.                                     date
  9.                      int sep        the character to be used to space the
  10.                                     fields
  11.                      int zpad       0 =  no leading zeros
  12.                                     1 =  leading zeros to be printed
  13.                                     ? =  free-form
  14.  
  15.    Return value:     void
  16. *****/
  17.  
  18. #include <stdio.h>
  19. #include <dos.h>
  20. #include <string.h>
  21.  
  22. void makedate(char *buff, int sep, int zpad)
  23. {
  24.    char form[20];
  25.    union REGS ireg;
  26.  
  27.    ireg.h.ah = 0x2a;
  28.    intdos(&ireg, &ireg);
  29.  
  30.    switch (zpad) {
  31.       case 0:
  32.          strcpy(form, "%02d%c%02d%c%02d");   /* Zero padding   */
  33.          break;
  34.       case 1:
  35.          strcpy(form, "%2d%c%2d%c%2d");      /* blank space    */
  36.          break;
  37.       default:
  38.          strcpy(form, "%d%c%d%c%d");         /* free form      */
  39.          break;
  40.    }
  41.    sprintf(buff, form, ireg.h.dh, sep, ireg.h.dl, sep, ireg.x.cx - 1900);
  42. }
  43.