Skip to content

Commit 758ae69

Browse files
authored
Fix leap year definition
In the Gregorian calendar three criteria must be taken into account to identify leap years: * The year can be evenly divided by 4; * If the year can be evenly divided by 100, it is NOT a leap year, unless; * The year is also evenly divisible by 400. Then it is a leap year. This means that in the Gregorian calendar, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years. via https://www.timeanddate.com/date/leapyear.html
1 parent 3bcda37 commit 758ae69

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/iii_conventions/n30DestructuringDeclarations.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ fun isLeapDay(date: MyDate): Boolean {
1717
todoTask30()
1818
// val (year, month, dayOfMonth) = date
1919
//
20+
// fun isLeapYear(year: Int): Boolean = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
21+
//
2022
// // 29 February of a leap year
21-
// return year % 4 == 0 && month == 2 && dayOfMonth == 29
23+
// return isLeapYear(year) && month == 2 && dayOfMonth == 29
2224
}

0 commit comments

Comments
 (0)