Difference between revisions of "Template:IsLeapYear"
(New page: {{{{{subst|}}}#expr: ((({{{1|{{CURRENTYEAR}}}}}) mod 4 = 0) and (({{{1|{{CURRENTYEAR}}}}}) mod 100 != 0)) or (({{{1|{{CURRENTYEAR}}}}}) mod 400 = 0)}}<noinclude> </noinclude>) |
(<noinclude>Category:Calendar templates</noinclude>) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{{{{subst|}}}#expr: ((({{{1|{{CURRENTYEAR}}}}}) mod 4 = 0) and (({{{1|{{CURRENTYEAR}}}}}) mod 100 != 0)) or (({{{1|{{CURRENTYEAR}}}}}) mod 400 = 0)}}<noinclude> | {{{{{subst|}}}#expr: ((({{{1|{{CURRENTYEAR}}}}}) mod 4 = 0) and (({{{1|{{CURRENTYEAR}}}}}) mod 100 != 0)) or (({{{1|{{CURRENTYEAR}}}}}) mod 400 = 0)}}<noinclude> | ||
+ | ---- | ||
+ | ; Usage: | ||
+ | : {{Tlx|{{PAGENAME}}|''year''}} | ||
+ | : ''year'' defaults to {{evaldemo|CURRENTYEAR|=}}. | ||
+ | ; Formula: | ||
+ | : <nowiki>{{#expr: ((({{{1}}}) mod 4 = 0) and (({{{1}}}) mod 100 != 0)) or (({{{1}}}) mod 400 = 0)}}</nowiki> | ||
+ | : Use {{subst:{{PAGENAME}}}} to get this code ready for [[Help:Substitution#Optional_substitution|optional substitution]] into another template. | ||
+ | ; Sanity check: | ||
+ | : {{evaldemo/3|{{PAGENAME}}|2007}}, 2007 is no leap year. | ||
+ | : {{evaldemo/3|{{PAGENAME}}|2008}}, 2008 is a leap year. | ||
+ | : {{evaldemo/3|{{PAGENAME}}|2100}}, 2100 is no leap year. | ||
+ | : {{evaldemo/3|{{PAGENAME}}|2400}}, 2400 is a leap year. | ||
+ | : {{evaldemo/3|{{PAGENAME}}|1500}}, [[w:en:Proleptic Gregorian calendar|proleptic Gregorian calendar]]. | ||
+ | : {{evaldemo/3|{{PAGENAME}}|-100}} for 101 BC (mostly pointless). | ||
+ | : {{evaldemo/3|{{PAGENAME}}|502*4-8}}, guess why. | ||
+ | |||
+ | Results for fractions like {{evaldemo/3|{{PAGENAME}}|2000.9|5==}} are unspecified, even if it apparently gives an "expected" result at the moment this might change without notice. | ||
</noinclude> | </noinclude> | ||
+ | <noinclude>[[Category:Calendar templates|IsLeapYear]]</noinclude> |
Latest revision as of 06:16, April 9, 2008
1
- Usage:
- {{IsLeapYear|year}}
- year defaults to {{
CURRENTYEAR
}} = 2024
.
- 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
}} = 1
are unspecified, even if it apparently gives an "expected" result at the moment this might change without notice.