Template:Is decade/doc

From Wikisource
Jump to navigation Jump to search

Usage[edit]

This template can be used in other templates to check or analyse an input entered in the the form YYYYs (ie. the format used in Works by decade‎, Births by decade‎ and Deaths by decade‎).

{{is decade|input=|function=}}

The template can be used without named parameters as well. The most basic usage is:

{{is decade|}}

Input[edit]

The input must be in the form of YYYYs or YYYYs BCE. The maximum value is 2100s and the minimum value is 2000s BCE. The inputs 0s and 0s BCE are treated as separate periods (ie. the year 1-10 CE and 1-10 BCE respectively).

Function[edit]

The 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 Removes the plural "s" from the input.
1 Index Returns a number counting number of decades from 0s.
ie.10s = 1, 10s BCE = -1.
2 Absolute Returns the numeric part of the input only.
3 Logic Returns a 1 (one) if the input is a recognised decade.


If the input is not a recognised decade, this template will return FALSE; unless function 3 is selected, in which case it will return 0 (zero).

Examples[edit]

Basic[edit]

{{is decade|1980s}}

1980

{{is decade|input=1980s}}

1980

{{is decade|input=1980s|function=0}}

1980

Index[edit]

{{is decade|input=1980s|function=1}}

198

{{is decade|input=0s|function=1}}

0

{{is decade|input=0s BCE|function=1}}

-1

{{is decade|input=1980s BCE|function=1}}

-199

Absolute[edit]

{{is decade|input=1980s|function=2}}

1980

{{is decade|input=0s|function=2}}

0

{{is decade|input=0s BCE|function=2}}

0

{{is decade|input=1980s BCE|function=2}}

1980

Logic[edit]

{{is decade|input=1980s|function=3}}

1

{{is decade|input=1980|function=3}}

0

Note that the "s" has been removed from the input. This is a year and not a decade.

{{is decade|input=Foo|function=3}}

0

Unrecognised input[edit]

{{is decade|input=Foo}}

FALSE

{{is decade|input=Foo|function=3}}

0

Notes[edit]

An alternative form of using function 3 (logic) is to combine this template with {{is number}}.

{{is number|{{is decade|input=1980s|function=2}}}}

1

{{is number|{{is decade|input=Foo|function=2}}}}


See also[edit]