Hi guys, any help appreciated here. This is what I have so far.
int getDaysBetweenDates(int day, int month, int year, int day2, int month2, int year2)
{
if(isFirstDateGreaterThanSecond(int month1, int day1, int year1, int month2, int day2, int year2))
{
return getDaysBetweenDates(month2, day2, year2, month1, day1, year1)
}
else if(year1 == year2)
{
return getDayNumber(month2, day2, year2) - getDayNumber(month1, day1, year1);
}
else getDayNumber(month2, day2, year2) + getDayNumber(month1, day1, year1, 12, 31, year2 - 1);
}
int getDayNumber(int month1, int day 1, int year1, int month2, int day2, int year2)
{
int a, y, m, yearBefore, daynumber;
int daynumber = 0;
int julianDay = 0;
cin>>month1>>day1>>year1;
for(yearBefore=year1; yearBefore >= (year1-1); yearBefore--)
{
a = (14 - month1) / 12;
y = yearBefore + 4800 - a;
m = month + 12 * a - 3;
julianDay = day + (153 * m + 2) / 5 + y * 365 + y / 4 - y/100 + y/400 - 32045;
if(day1==0)
{
daynumber1 += julianDay;
}
else
{
daynumber1 -= julianDay;
}
day = 31;
month = 12;
}
return daynumber1;
}
These are just parts of a much bigger program. My question is.. I need to know how to pass the variables to my getDayNumber function. But here is the problem I have.
If I do a call to getdaynumber like, "getdaynumber(month2, day2, year2)" how do I get it to return the value for this date? Instead of month1, day1, year1?