Files
JavaScript/Maths/LeapYear.js
Roland Hummel 86d333ee94 feat: Test running overhaul, switch to Prettier & reformat everything (#1407)
* chore: Switch to Node 20 + Vitest

* chore: migrate to vitest mock functions

* chore: code style (switch to prettier)

* test: re-enable long-running test

Seems the switch to Node 20 and Vitest has vastly improved the code's and / or the test's runtime!

see #1193

* chore: code style

* chore: fix failing tests

* Updated Documentation in README.md

* Update contribution guidelines to state usage of Prettier

* fix: set prettier printWidth back to 80

* chore: apply updated code style automatically

* fix: set prettier line endings to lf again

* chore: apply updated code style automatically

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
2023-10-04 02:38:19 +05:30

19 lines
757 B
JavaScript

/**
* isLeapYear :: Number -> Boolean
*
* Check if a year is a leap year or not. A leap year is a year which has 366 days.
* For the extra +1 day the February month contains 29 days instead of 28 days.
*
* The logic behind the leap year is-
* 1. If the year is divisible by 400 then it is a leap year.
* 2. If it is not divisible by 400 but divisible by 100 then it is not a leap year.
* 3. If the year is not divisible by both 400 and 100 but divisible by 4 then a leap year.
* 4. Other cases except the describing ones are not a leap year.
*
* @param {number} year
* @returns {boolean} true if this is a leap year, false otherwise.
*/
export const isLeapYear = (year) => {
return year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)
}