Jump to content

Template:Century name from decade or year/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m →‎See also: +{{String-handling templates}}
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{Intricate template}}
{{High use|49377 }}
{{High use|49377 }}
When supplied with a 2-, 3- or 4-digit year or decade, returns the name of the century.
When supplied with a 1-, 2-, 3- or 4-digit year or decade, returns the name of the century.


Mostly used in categorisation.
Mostly used in categorisation.


== Parameters ==
== Parameters ==
# The first parameter is required: either a 2-, 3-, or 4-digit year (e.g. 61, 905, 1839) or a 2-, 3-, or 4--digit decade (e.g. 60s, 900s, 1830s)
# The first parameter is required: either a 1-, 2-, 3-, or 4-digit year (e.g. 61, 905, 1839) or a 2-, 3-, or 4--digit decade (e.g. 60s, 900s, 1830s)
# The second parameter is optional. The single word "dash" changes the output from "nth century" to "nth-century"
# The second parameter is optional. The single word "dash" changes the output from "nth century" to "nth-century"
# An optional "nomatch" parameter may be used to specify text to be return if the input cannot be processed. Default behaviour is return an empty string if there is no match
# An optional "nomatch" parameter may be used to specify text to be return if the input cannot be processed. Default behaviour is return an empty string if there is no match
Line 46: Line 45:
* <code><nowiki>{{Century name from decade or year|123abc|nomatch=garbage input}}</nowiki></code> → {{Century name from decade or year|123abc|nomatch=garbage input}}
* <code><nowiki>{{Century name from decade or year|123abc|nomatch=garbage input}}</nowiki></code> → {{Century name from decade or year|123abc|nomatch=garbage input}}
* <code><nowiki>{{Century name from decade or year|Fastidious French flying flamingoes flounce furiously|nomatch=NOMATCH}}</nowiki></code> → {{Century name from decade or year|Fastidious French flying flamingoes flounce furiously|nomatch=NOMATCH}}
* <code><nowiki>{{Century name from decade or year|Fastidious French flying flamingoes flounce furiously|nomatch=NOMATCH}}</nowiki></code> → {{Century name from decade or year|Fastidious French flying flamingoes flounce furiously|nomatch=NOMATCH}}

== Redirects ==
* {{tl|Century name from decade}}
* {{tl|Century name from year}}


== TemplateData ==
== TemplateData ==
Line 54: Line 57:
"1": {
"1": {
"label": "Year or decade",
"label": "Year or decade",
"description": "a 4-digit-year (e.g. '1957') or a 4-digit-decade (e.g. '1760s') ",
"description": "a 1-, 2-, 3- or 4-digit-year (e.g. '1957') or a 4-digit-decade (e.g. '1760s') ",
"type": "number",
"type": "number",
"default": ""
"default": ""
Line 60: Line 63:
"2": {
"2": {
"label": "dash",
"label": "dash",
"description": "If this parameter is dash, then the century number is followed by a dash rather than a space, i.e. '16th-century' instead of the default '16th-century'",
"description": "If this parameter is dash, then the century number is followed by a dash rather than a space, i.e. '16th-century' instead of the default '16th century'",
"type": "string",
"type": "string",
"default": ""
"default": ""
Line 66: Line 69:
"nomatch": {
"nomatch": {
"label": "No match text",
"label": "No match text",
"description": "If the input is not a 4-digit year or a 4-digit decade, output the \"nomatch\" value. Defaults to blank.",
"description": "If the input is not a 1-, 2-, 3- or 4-digit year or decade, output the \"nomatch\" value. Defaults to blank.",
"type": "string"
"type": "string"
}
}
},
},
"description": "Returns the name of the century for a 4-digit year or a 4-digit decade."
"description": "Returns the name of the century for a 1-, 2-, 3- or 4-digit year or decade."
}
}
</templatedata>
</templatedata>


== See also ==
== See also ==
{{Columns-list|
* [[Template:Title year]]
* [[Template:Title year range]]
{{Title year see also}}
}}
* [[Template:Title decade]]

* [[Template:Century name from title year]]
{{String-handling templates}}
* [[Template:Century name from title decade]]


<includeonly>{{sandbox other||
<includeonly>{{sandbox other||

Latest revision as of 16:30, 29 August 2021

When supplied with a 1-, 2-, 3- or 4-digit year or decade, returns the name of the century.

Mostly used in categorisation.

Parameters

[edit]
  1. The first parameter is required: either a 1-, 2-, 3-, or 4-digit year (e.g. 61, 905, 1839) or a 2-, 3-, or 4--digit decade (e.g. 60s, 900s, 1830s)
  2. The second parameter is optional. The single word "dash" changes the output from "nth century" to "nth-century"
  3. An optional "nomatch" parameter may be used to specify text to be return if the input cannot be processed. Default behaviour is return an empty string if there is no match

Usage

[edit]
  • {{Century name from decade or year|YYYY}}
  • {{Century name from decade or year|YYYY|dash}}
  • {{Century name from decade or year|YYY0s}}
  • {{Century name from decade or year|YYY0s|dash}}
  • {{Century name from decade or year|YYYY|nomatch=FAIL}}
  • {{Century name from decade or year|YYYY|dash|nomatch=FAIL}}
  • {{Century name from decade or year|YYY0s|nomatch=FAIL}}
  • {{Century name from decade or year|YYY0s|dash|nomatch=FAIL}}

Examples

[edit]
  • {{Century name from decade or year|8}} → 1st century
  • {{Century name from decade or year|63}} → 1st century
  • {{Century name from decade or year|421}} → 5th century
  • {{Century name from decade or year|1707}} → 18th century
  • {{Century name from decade or year|1514|dash}} → 16th-century
  • {{Century name from decade or year|0s}} → 1st century
  • {{Century name from decade or year|40s}} → 1st century
  • {{Century name from decade or year|550s}} → 6th century
  • {{Century name from decade or year|1920s}} → 20th century
  • {{Century name from decade or year|2030s|dash}} → 21st-century

Errors

[edit]

Empty or inappropriate parameters produce no output, unless the "nomatch" paremeter is set.

  • {{Century name from decade or year}}
  • {{Century name from decade or year|7}} → 1st century
  • {{Century name from decade or year|123abc}}
  • {{Century name from decade or year|French flying flamingoes flounce furiously}}

With "nomatch"

  • {{Century name from decade or year|nomatch=FAILED}} → FAILED
  • {{Century name from decade or year|7|nomatch=Aaaaaaaaaargh}} → 1st century
  • {{Century name from decade or year|123abc|nomatch=garbage input}} → garbage input
  • {{Century name from decade or year|Fastidious French flying flamingoes flounce furiously|nomatch=NOMATCH}} → NOMATCH

Redirects

[edit]

TemplateData

[edit]
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Century name from decade or year in articles based on its TemplateData.

TemplateData for Century name from decade or year

Returns the name of the century for a 1-, 2-, 3- or 4-digit year or decade.

Template parameters

ParameterDescriptionTypStatus
Year or decade1

a 1-, 2-, 3- or 4-digit-year (e.g. '1957') or a 4-digit-decade (e.g. '1760s')

Default
Numberoptional
dash2

If this parameter is dash, then the century number is followed by a dash rather than a space, i.e. '16th-century' instead of the default '16th century'

Default
Stringoptional
No match textnomatch

If the input is not a 1-, 2-, 3- or 4-digit year or decade, output the "nomatch" value. Defaults to blank.

Stringoptional

See also

[edit]