Skip to content

isLeapYear

Returns true if the given year is a leap year.

A year is a leap year when it is divisible by 4, except century years which must also be divisible by 400.

Available since v2.0.0

import { isLeapYear } from '@helpers4/date';
isLeapYear(year: number): boolean
ParameterTypeDescription
yearnumberA full year number (e.g. 2024)

boolean — true if the year is a leap year

isLeapYear(2024) // => true
isLeapYear(2025) // => false
isLeapYear(2000) // => true  (divisible by 400)
isLeapYear(1900) // => false (century, not divisible by 400)

View source on GitHub