Skip to content

Commit

Permalink
Update APCalendar.java
Browse files Browse the repository at this point in the history
  • Loading branch information
saaltamirano1 committed May 4, 2024
1 parent f70c960 commit 130bde8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/APCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ private static boolean isLeapYear(int year)
public static int numberOfLeapYears(int year1, int year2)
{
int count = 0;
for(int i = year1; i < year2; i++){
if(isLeapYear(i) == true){
int count = 0;
for (int i = year1; i<=year2; i++){
if (isLeapYear(i)){
count++;
}
}
Expand Down Expand Up @@ -56,9 +57,7 @@ private static int dayOfYear(int month, int day, int year)
*/
public static int dayOfWeek(int month, int day, int year)
{
int first = firstDayOfYear(year);
int n = dayOfWeek(month,day,year);
int day = (first + n - 1) % 7;
return day;
int additionalDays = dayOfYear(month, day, year) - 1;
return (firstDayOfYear(year) + additionalDays) % 7;
}
}

0 comments on commit 130bde8

Please sign in to comment.