Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/datetime/mod.ts>isUtcLeap

The Deno Standard Library
Go to Latest
function isUtcLeap
import { isUtcLeap } from "https://deno.land/std@0.222.1/datetime/mod.ts";

Returns whether the given year is a leap year in UTC time. This always returns the same value regardless of the local timezone.

This is based on https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year.

Examples

Passing Date objects

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

isUtcLeap(new Date("2000-01-01")); // true

isUtcLeap(new Date("December 31, 1999 23:59:59 GMT-01:00")); // true

Passing number values

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

isUtcLeap(2000); // true

isUtcLeap(1999); // false

Parameters

year: Date | number

The year in number or Date format.

Returns

boolean

true if the given year is a leap year; false otherwise.