Bản mẫu:Là năm/tài liệu

Usage

sửa

This 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

sửa

The 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

sửa

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 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

sửa

Basic

sửa
{{is year|50 BCE}}

50

{{is year|input=50 BCE}}

50

{{is year|input=50 BCE|function=0}}

50

{{is year|1930}}

1930

Decade

sửa
{{is year|input=1930|function=1}}

thập niên 1930

{{is year|input=75|function=1}}

thập niên 70

{{is year|input=75 BCE|function=1}}

thập niên 70 TCN

{{is year|input=1930 BCE|function=1}}

thập niên 1930 TCN

Century

sửa
{{is year|input=2000|function=2}}

thế kỷ 20

{{is year|input=1930|function=2}}

thế kỷ 20

{{is year|input=75|function=2}}

thế kỷ 1

{{is year|input=75 BCE|function=2}}

thế kỷ 1 TCN

{{is year|input=1930 BCE|function=2}}

thế kỷ 20 TCN

Logic

sửa
{{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

sửa
{{is year|input=1930|function=4}}

1

{{is year|input=0|function=4}}

0

{{is year|input=1930 BCE|function=4}}

-1

Unrecognised input

sửa
{{is year|input=Foo}}

FALSE

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

0

{{is year|input=Foo|function=4}}

0

Notes

sửa

An 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

sửa