/*****
                              makedate()

      This function formats the system date into the string passed to the
   function using interrupt 0x21.

   Argument list:    char *buff     pointer to a character array for the
                                    date
                     int sep        the character to be used to space the
                                    fields
                     int zpad       0 =  no leading zeros
                                    1 =  leading zeros to be printed
                                    ? =  free-form

   Return value:     void
*****/

#include <stdio.h>
#include <dos.h>
#include <string.h>

void makedate(char *buff, int sep, int zpad)
{
   char form[20];
   union REGS ireg;

   ireg.h.ah = 0x2a;
   intdos(&ireg, &ireg);

   switch (zpad) {
      case 0:
         strcpy(form, "%02d%c%02d%c%02d");   /* Zero padding   */
         break;
      case 1:
         strcpy(form, "%2d%c%2d%c%2d");      /* blank space    */
         break;
      default:
         strcpy(form, "%d%c%d%c%d");         /* free form      */
         break;
   }
   sprintf(buff, form, ireg.h.dh, sep, ireg.h.dl, sep, ireg.x.cx - 1900);
}
