Difference between revisions of "Template:IsLeapYear/doc"

From blackwiki
Jump to navigation Jump to search
imported>Verdy p
m
imported>Vanisaac
m (→‎Sanity check: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
 
(20 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{Template doc page}}
+
{{Documentation subpage}}
 
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
 
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
 
----
 
----
; Usage&#58;
+
=== Usage ===
 +
{{shortcut|template:ly}}
 
: {{Tlx|IsLeapYear|''year''}}
 
: {{Tlx|IsLeapYear|''year''}}
: ''year'' defaults to {{evaldemo|CURRENTYEAR|&#61;}}. It must be specified in the Gregorian calendar, extended to all epochs using linear year numbering: use the [[proleptic Gregorian calendar]] in Christian Era before the change, and the astronomical year convention (using negative numbers, and year 0) in all years AD before the Christian era (there's a difference of 1 in absolute value).
+
: ''year'' defaults to {{evaldemo|CURRENTYEAR|&#61;}}. It must be specified in the Gregorian calendar, extended to all epochs using linear year numbering: use the [[proleptic Gregorian calendar]] in Christian Era before the change, and the astronomical year convention (using negative numbers, and year 0) in all years BC before the Christian era (there's a difference of 1 in absolute value).
; Formula&#58;
+
===Parameters===
: <nowiki>{{#expr: ((({{{1}}}) mod 4 = 0) and (({{{1}}}) mod 100 != 0)) or (({{{1}}}) mod 400 = 0)}}</nowiki>
+
* ''Unnamed parameter'' The year to calculate with (default: {{CURRENTYEAR}})
: Use {&#123;subst:IsLeapYear&#125;} to get this code ready for [[Help:Substitution#Optional_substitution|optional substitution]] into another template.
+
* {{para|yes}} What to output if it is a leap year (default : 1)
; Sanity check&#58;
+
* {{para|no}} What to output if it isn't a leap year (default: 0)
: {{evaldemo/3|IsLeapYear|2000}}, 2000 is effectively a leap year.
+
=== Formula ===
: {{evaldemo/3|IsLeapYear|2001}}, 2001 is not a leap year.
+
The template currently uses Wikimedia function time (#time). It is the same as if 4 mod year = 0  and 100 mod year ≠ 0, then not a leap year, unless 400 mod year = 0, then it is a leap year.
: {{evaldemo/3|IsLeapYear|2004}}, 2004 is a leap year.
 
: {{evaldemo/3|IsLeapYear|2007}}, 2007 is not a leap year.
 
: {{evaldemo/3|IsLeapYear|2008}}, 2008 is a leap year.
 
: {{evaldemo/3|IsLeapYear|2009}}, 2009 is not a leap year.
 
: {{evaldemo/3|IsLeapYear|2100}}, 2100 is not a leap year in the Gregorian calendar.
 
: {{evaldemo/3|IsLeapYear|2400}}, 2400 is effectively a leap year.
 
: {{evaldemo/3|IsLeapYear|1900}}, 1900 is not a leap year in the Gregorian calendar.
 
: {{evaldemo/3|IsLeapYear|1800}}, 1800 is not a leap year in the Gregorian calendar.
 
: {{evaldemo/3|IsLeapYear|1600}}, 1600 is effectively a leap year.
 
: {{evaldemo/3|IsLeapYear|1700}}, 1700 is not a leap year in the Gregorian calendar.
 
: {{evaldemo/3|IsLeapYear|1500}}, 1500 is not a leap year [[Proleptic Gregorian calendar|proleptic Gregorian calendar]] (but is leap in the actual Julian calendar).
 
: {{evaldemo/3|IsLeapYear|-100}} for 101 BC (mostly pointless).
 
: {{evaldemo/3|IsLeapYear|502*4-8}}, 2000 is effectively a leap year.
 
  
Results for fractions like {{evaldemo/3|IsLeapYear|2000.9|5==}} are unspecified, even if it apparently gives an "expected" result at the moment this might change without notice.
+
=== Sanity check ===
 +
: {{evaldemo/3|IsLeapYear|2000}}: 2000 AD is ''effectively'' a leap year ''(in both the Julian and Gregorian calendars)''.
 +
: {{evaldemo/3|IsLeapYear|502*4-8}}: 2000 AD is ''effectively'' a leap year ''(in both the Julian and Gregorian calendars)''.
 +
: {{evaldemo/3|IsLeapYear|2001}}: 2001 AD is not a leap year.
 +
: {{evaldemo/3|IsLeapYear|2004}}: 2004 AD is a leap year.
 +
: {{evaldemo/3|IsLeapYear|2005}}: 2005 AD is not a leap year.
 +
: {{evaldemo/3|IsLeapYear|2007}}: 2007 AD is not a leap year.
 +
: {{evaldemo/3|IsLeapYear|2008}}: 2008 AD is a leap year.
 +
: {{evaldemo/3|IsLeapYear|2009}}: 2009 AD is not a leap year.
 +
: {{evaldemo/3|IsLeapYear|2100}}: 2100 AD is not a leap year in the Gregorian calendar ''(but not in the Julian calendar)''.
 +
: {{evaldemo/3|IsLeapYear|2400}}: 2400 AD is ''effectively'' a leap year ''(in both the Julian and Gregorian calendars)''.
 +
: {{evaldemo/3|IsLeapYear|1900}}: 1900 AD is not a leap year in the Gregorian calendar ''(but not in the Julian calendar)''.
 +
: {{evaldemo/3|IsLeapYear|1800}}: 1800 AD is not a leap year in the Gregorian calendar ''(but not in the Julian calendar)''.
 +
: {{evaldemo/3|IsLeapYear|1700}}: 1700 AD is not a leap year in the Gregorian calendar ''(but not in the Julian calendar)''.
 +
: {{evaldemo/3|IsLeapYear|1600}}: 1600 AD is ''effectively'' a leap year ''(in both the Julian and Gregorian calendars)''.
 +
: {{evaldemo/3|IsLeapYear|1500}}: 1500 AD is not a leap year in the [[proleptic Gregorian calendar]] ''(but is leap in the actual Julian calendar)''.
 +
: {{evaldemo/3|IsLeapYear|0}}: 1 BC is a leap year in the astronomical calendar ''(mostly pointless for actual calendars of such epoch, but correct in the astronomical calendar where it is year 0)''.
 +
: {{evaldemo/3|IsLeapYear|-100}}: 101 BC is not a leap year in the astronomical calendar ''(mostly pointless for actual calendars of such epoch, but correct in the astronomical calendar where it is year -100)''.
  
<includeonly>
+
Results for fractions like {{evaldemo/3|IsLeapYear|2000.9|5==}} are rounded down (floor).
 +
 
 +
<includeonly>{{Sandbox other||
 
<!-- ADD CATEGORIES BELOW THIS LINE -->
 
<!-- ADD CATEGORIES BELOW THIS LINE -->
 
[[Category:Date mathematics templates|{{PAGENAME}}]]
 
[[Category:Date mathematics templates|{{PAGENAME}}]]
  
 
<!-- ADD INTERWIKIS BELOW THIS LINE -->
 
<!-- ADD INTERWIKIS BELOW THIS LINE -->
[[hsb:Předłoha:IsLeapYear]]
+
[[ja:Template:Is-leap-year]]
[[it:Template:Bisestile]]
+
[[ur:سانچہ:IsLeapYear]]
[[mk:Шаблон:IsLeapYear]]
+
 
[[nl:Sjabloon:Schrikkeljaar]]
+
}}</includeonly>
[[pt:Predefinição:AnoBissexto]]
 
</includeonly>
 

Latest revision as of 22:33, 25 April 2020


Usage

{{IsLeapYear|year}}
year defaults to {{CURRENTYEAR}} = 2026. It must be specified in the Gregorian calendar, extended to all epochs using linear year numbering: use the proleptic Gregorian calendar in Christian Era before the change, and the astronomical year convention (using negative numbers, and year 0) in all years BC before the Christian era (there's a difference of 1 in absolute value).

Parameters

  • Unnamed parameter The year to calculate with (default: 2026)
  • |yes= What to output if it is a leap year (default : 1)
  • |no= What to output if it isn't a leap year (default: 0)

Formula

The template currently uses Wikimedia function time (#time). It is the same as if 4 mod year = 0 and 100 mod year ≠ 0, then not a leap year, unless 400 mod year = 0, then it is a leap year.

Sanity check

{{ IsLeapYear | 2000 }} gives 1: 2000 AD is effectively a leap year (in both the Julian and Gregorian calendars).
{{ IsLeapYear | 502*4-8 }} gives 1: 2000 AD is effectively a leap year (in both the Julian and Gregorian calendars).
{{ IsLeapYear | 2001 }} gives 0: 2001 AD is not a leap year.
{{ IsLeapYear | 2004 }} gives 1: 2004 AD is a leap year.
{{ IsLeapYear | 2005 }} gives 0: 2005 AD is not a leap year.
{{ IsLeapYear | 2007 }} gives 0: 2007 AD is not a leap year.
{{ IsLeapYear | 2008 }} gives 1: 2008 AD is a leap year.
{{ IsLeapYear | 2009 }} gives 0: 2009 AD is not a leap year.
{{ IsLeapYear | 2100 }} gives 0: 2100 AD is not a leap year in the Gregorian calendar (but not in the Julian calendar).
{{ IsLeapYear | 2400 }} gives 1: 2400 AD is effectively a leap year (in both the Julian and Gregorian calendars).
{{ IsLeapYear | 1900 }} gives 0: 1900 AD is not a leap year in the Gregorian calendar (but not in the Julian calendar).
{{ IsLeapYear | 1800 }} gives 0: 1800 AD is not a leap year in the Gregorian calendar (but not in the Julian calendar).
{{ IsLeapYear | 1700 }} gives 0: 1700 AD is not a leap year in the Gregorian calendar (but not in the Julian calendar).
{{ IsLeapYear | 1600 }} gives 1: 1600 AD is effectively a leap year (in both the Julian and Gregorian calendars).
{{ IsLeapYear | 1500 }} gives 0: 1500 AD is not a leap year in the proleptic Gregorian calendar (but is leap in the actual Julian calendar).
{{ IsLeapYear | 0 }} gives 1: 1 BC is a leap year in the astronomical calendar (mostly pointless for actual calendars of such epoch, but correct in the astronomical calendar where it is year 0).
{{ IsLeapYear | -100 }} gives 0: 101 BC is not a leap year in the astronomical calendar (mostly pointless for actual calendars of such epoch, but correct in the astronomical calendar where it is year -100).

Results for fractions like {{ IsLeapYear | 2000.9 }} = 1 are rounded down (floor).