Figure 4: Test driver for date routines

/////////////////////////////////////////////////////////////////
//  Function:  Test Driver
//
//  Description:  1) Takes an input in MMDDYY format, and also
//  century digits to generate MWDDYY date. Calculates weekdays
//  for subsequent century digits to compare it with a W field of
//  a considered date. Correct century digits produce the same
//  weekday. 2) Convert MMDDYY date to (DDDDD)h; 3) Convert 
//  MMDDYY to DDD number with 64 as a base. 
/////////////////////////////////////////////////////////////////
int main (void)
{
    char MMDDCCYYStartDate[9], MMDDYYDate[7], MWDDYYDate[7],
         DDDDDBuffer[6],DDDBuffer[4], CCDigits[3], WeekDay; 
    int CC, CCFound; 
  
    strcpy(MMDDCCYYStartDate, "01011600");  /* 01/01/1600 */
    while (1) {
        memset(DDDDDBuffer, '\0', 6);
        memset(DDDBuffer, '\0', 4);
        (void)printf(
            "Enter date in MMDDYY Format or Q(q) to exit.\n");
        scanf ("%s", MMDDYYDate);
        if (MMDDYYDate[0]=='Q' || MMDDYYDate[0]=='q') {
            (void)printf("Have a good day.\n");
            exit(0);
        }
        (void)printf(
            "Enter First Two Digits of Year(19, 20, etc.\n");
        scanf ("%s", CCDigits);
        CC=atoi(CCDigits); 
        if (CC<16 || CC>24) {
            (void)printf(
                "Valid values are 16 <= CC <= 24. Repeat.\n");
            continue;
        }
        MMDDYYToMWDDYY(MMDDYYDate, CC, MWDDYYDate);
        CCFound =FindCenturyDigits(MWDDYYDate); 
        if (CCFound==CC) {
            (void)printf("MWDDYYDate = %s\n", MWDDYYDate); 
            WeekDay =
                (char)(atoi(XDigitToDecimal(MWDDYYDate[1]))%7);
            (void)printf("CC = %d, W (DOW) =%d; OK.\n", 
                CC, (int)WeekDay); 
        } 
        MMDDYYToDDDDDh(CC, MMDDCCYYStartDate, MMDDYYDate, 
            DDDDDBuffer);
        (void)printf("DDDDDh = %s\n", DDDDDBuffer); 
        MMDDYYToDDDBased64(CC, MMDDCCYYStartDate, MMDDYYDate,
            DDDBuffer); 
        (void)printf("DDD64 = %s\n", DDDBuffer); 
        continue;
    }    
    return (0);
} 


/* End of File */