// tdate2.cpp

#include <stdio.h>
#include <stdlib.h>
#include "date2.h"

main()
{
    int m, d, y, nargs;
    
    // Read in two dates - assume 1st precedes 2nd
    fputs("Enter a date, MM/DD/YY> ",stderr);
    nargs = scanf("%d/%d/%d%*c", &m,&d,&y);
    if (nargs != 3)
        return EXIT_FAILURE;
    Date d1(m,d,y);
            
    fputs("Enter a later date, MM/DD/YY> ",stderr);
    nargs = scanf("%d/%d/%d%*c", &m,&d,&y);
    if (nargs != 3)
        return EXIT_FAILURE;
    Date d2(m,d,y);
    
    // Compute interval in years, months, and days
    Date *result = d1.interval(d2);
    printf("years: %d, months: %d, days: %d\n",
        result->year, result->month, result->day);
    return EXIT_SUCCESS;
}

