Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/datetime/is_leap.ts>isUtcLeap

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function isUtcLeap
import { isUtcLeap } from "https://deno.land/std@0.190.0/datetime/is_leap.ts";

Returns whether the given date or year (in number) is a leap year or not in UTC time. This always returns the same value regardless of the local timezone. based on: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year

Examples

Example 1

import { isUtcLeap } from "https://deno.land/std@0.190.0/datetime/is_leap.ts";

isUtcLeap(2000); // => returns true regardless of the local timezone
isUtcLeap(new Date("2000-01-01")); // => returns true regardless of the local timezone
isUtcLeap(new Date("January 1, 2000 00:00:00 GMT+00:00")); // => returns true regardless of the local timezone
isUtcLeap(new Date("December 31, 2000 23:59:59 GMT+00:00")); // => returns true regardless of the local timezone
isUtcLeap(new Date("January 1, 2000 00:00:00 GMT+01:00")); // => returns false regardless of the local timezone
isUtcLeap(new Date("December 31, 2000 23:59:59 GMT-01:00")); // => returns false regardless of the local timezone
isUtcLeap(new Date("January 1, 2001 00:00:00 GMT+01:00")); // => returns true regardless of the local timezone
isUtcLeap(new Date("December 31, 1999 23:59:59 GMT-01:00")); // => returns true regardless of the local timezone

Parameters

year: Date | number

year in number or Date format

Returns

boolean