Skip to content

Commit

Permalink
fix: leap year's days
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiYou-TW committed May 30, 2024
1 parent 8bdc28f commit f12d34d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw4/src/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Calculator {
// ignore 0 index
let daysIn = [0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (this.#isLeapYear(year))
daysIn[2] = 28;
else
daysIn[2] = 29;
else
daysIn[2] = 28;

numDays = day2 + (daysIn[month1] - day1);

Expand Down

0 comments on commit f12d34d

Please sign in to comment.