Skip to content

Instantly share code, notes, and snippets.

@dj-amadeous
Created October 23, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj-amadeous/bad3f52a6e0c86a68f29ba55fa34bf9a to your computer and use it in GitHub Desktop.
Save dj-amadeous/bad3f52a6e0c86a68f29ba55fa34bf9a to your computer and use it in GitHub Desktop.
comparing line 5 with method
else if ((yearDiff > 0) && (monthValid)) // Year2 is after Year 1
{
System.out.println();
daysBetween = daysToEndOfMonth(dd1,mm1);
daysBetween = daysOfMonth(daysBetween,mm1+1,12+1);
daysBetween = daysOfMonth(daysBetween,1,mm2);
daysBetween += dd2;
daysBetween += ((yearDiff-1)*365);// *-* add in 365 days for each year inbetween yyyy1 and yyyy2
}
public static int daysOfMonth(int days, int m1, int m2)
{
while (m1 < m2)
{
if (m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) // *-* write the missing test conditions
{
days = days + 30;// *-* fill in the missing action
}
else if (m1 == 2)
{
days = days + 28;
}
else
{
days = days + 31;
}
m1++;
}
return days;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment