#include <stdio.h>
#include "IdanLib.c"


int DifferentDates2(int date1, int date2)
{
    int temp_date1 = date1,
        temp_date2 = date2,
        new_date = 0;
    short days_date1,
          days_date2,
          months_date1,
          months_date2;
    BOOLEAN negative;
    
    days_date1 = temp_date1 % 100;
    days_date2 = temp_date2 % 100;
    temp_date1 /= 100;
    temp_date2 /= 100;
    months_date1 = temp_date1 % 100;
    months_date2 = temp_date2 % 100;
    temp_date1 /= 100;
    temp_date2 /= 100;

    days_date1 -= days_date2;
    months_date1 -= months_date2;
    temp_date1 -= temp_date2;

    negative = (months_date1 < 0);
    months_date1 += (negative * 12);
    temp_date1 += (negative * -1);

    negative = (days_date1 < 0);
    days_date1 += (negative * 30);
    months_date1 += (negative * -1);

    negative = TAKE_SIGNED(temp_date1);

    new_date = temp_date1;
    new_date *= 100;
    new_date += (months_date1 * (signed short)negative);
    new_date *= 100;
    new_date += (days_date1 * (signed short)negative);

    return (new_date);

}


void main(void)
{
    int date1, date2, new_date;
    printf("Enter 2 dates (yymmdd): ");
    scanf("%d%d", &date1, &date2);
    new_date = DifferentDates2(date1, date2);
    printf("%d\n", new_date);

}