Template:IsLeapYear

From Meta, a Wikimedia project coordination wiki

1


Usage:
{{IsLeapYear|year}}
year defaults to "{{CURRENTYEAR|=}}" gives "Template:CURRENTYEAR" [1].
Formula:
{{#expr: ((({{{1}}}) mod 4 = 0) and (({{{1}}}) mod 100 != 0)) or (({{{1}}}) mod 400 = 0)}}
Use {{subst:IsLeapYear}} to get this code ready for optional substitution into another template.
Sanity check:
{{IsLeapYear|2007}} gives 0, 2007 is no leap year.
{{IsLeapYear|2008}} gives 1, 2008 is a leap year.
{{IsLeapYear|2100}} gives 0, 2100 is no leap year.
{{IsLeapYear|2400}} gives 1, 2400 is a leap year.
{{IsLeapYear|1500}} gives 0, proleptic Gregorian calendar.
{{IsLeapYear|-100}} gives 0 for 101 BC (mostly pointless).
{{IsLeapYear|502*4-8}} gives 1, guess why.

Results for fractions like {{IsLeapYear|2000.9|||=}} gives 1 are unspecified, even if it apparently gives an "expected" result at the moment this might change without notice.