Template:Is year
FALSE
Usage
editThis template can be used in other templates to check or analyse a year, whether Common Era (CE) or Before Common Era (BCE).
{{is year|input=|function=}}
The template can be used without named parameters as well. The most basic usage is:
{{is year|}}
Input
editThe input must be in the form of YYYY
or YYYY BCE
. The maximum value is 2100
and the minimum value is 2000 BCE
. As there is no year 0 (zero), the input 0 is inappropriate.
Function
editThe function must be one of the numbers in this table. This parameter is optional. If not set, function 0 is the default.
Number | Function | Output |
---|---|---|
0 | Basic | Returns the numeric part of the input only. |
1 | Decade | Returns the decade corresponding to this year. |
2 | Century | Returns the century corresponding to this year. |
3 | Logic | Returns a 1 (one) if the input is a recognised year. |
4 | Common Era | Returns 1 (one) for years in the Common Era/Anno Domini. Returns -1 (minus one) for years Before Common Era. |
If the input is not a recognised year, this template will return FALSE
; unless function 3 or function 4 is selected, in which case it will return 0 (zero).
Examples
editBasic
edit{{is year|50 BCE}}
50
{{is year|input=50 BCE}}
50
{{is year|input=50 BCE|function=0}}
50
{{is year|1930}}
1930
Decade
edit{{is year|input=1930|function=1}}
1930s
{{is year|input=75|function=1}}
70s
{{is year|input=75 BCE|function=1}}
70s BCE
{{is year|input=1930 BCE|function=1}}
1930s BCE
Century
edit{{is year|input=2000|function=2}}
20th century
{{is year|input=1930|function=2}}
20th century
{{is year|input=75|function=2}}
1st century
{{is year|input=75 BCE|function=2}}
1st century BCE
{{is year|input=1930 BCE|function=2}}
20th century BCE
Logic
edit{{is year|input=1930|function=3}}
1
{{is year|input=1930s|function=3}}
0
Note that an "s" has been added to this input. This is a decade and not a year.
{{is year|input=Foo|function=3}}
0
Common Era
edit{{is year|input=1930|function=4}}
1
{{is year|input=0|function=4}}
0
{{is year|input=1930 BCE|function=4}}
-1
Unrecognised input
edit{{is year|input=Foo}}
FALSE
{{is year|input=Foo|function=3}}
0
{{is year|input=Foo|function=4}}
0
Notes
editAn alternative form of using function 3 (logic) is to combine this template with {{is number}}.
{{is number|{{is year|1930}}}}
1
{{is number|{{is year|Foo}}}}
See also
edit- {{is decade}}
- {{is century}}