function isLeap
isLeap(year: Date | number): booleanReturns whether the given date or year (in number) is a leap year or not in the local time zone. based on: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year
Examples
Example 1
Example 1
import { isLeap } from "@std/datetime/is_leap"; isLeap(new Date("1970-01-02")); // => returns false isLeap(new Date("1972-01-02")); // => returns true isLeap(new Date("2000-01-02")); // => returns true isLeap(new Date("2100-01-02")); // => returns false isLeap(1972); // => returns true
Some dates may return different values depending on your timezone.
Example 2
Example 2
import { isLeap } from "@std/datetime/is_leap"; isLeap(new Date("2000-01-01")); // => returns true if the local timezone is GMT+0, returns false if the local timezone is GMT-1 isLeap(2000); // => returns true regardless of the local timezone