View source code
Display the source code in std/datetime/date.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Function std.datetime.date.yearIsLeapYear
Whether the given Gregorian Year is a leap year.
bool yearIsLeapYear(
int year
) pure nothrow @nogc @safe;
Parameters
Name | Description |
---|---|
year | The year to to be tested. |
Example
foreach (year; [1, 2, 100, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010])
{
assert(!yearIsLeapYear(year));
assert(!yearIsLeapYear(-year));
}
foreach (year; [0, 4, 8, 400, 800, 1600, 1996, 2000, 2004, 2008, 2012])
{
assert(yearIsLeapYear(year));
assert(yearIsLeapYear(-year));
}
Authors
License
Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.