Template:Ordinal: Difference between revisions
meta>MSGJ use absolute value to determine suffix, per request |
meta>Tra change how |d is handled, per talk |
||
Line 1: | Line 1: | ||
{{{1}}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes | {{{1}}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes | ||
|<sup> | |<sup> | ||
}} | }}{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs({{{1}}}) mod 100}} | ||
|11|12|13=th | |11|12|13=th | ||
|{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs{{{1}}} mod 10}} | |{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs{{{1}}} mod 10}} | ||
|1=st | |1=st | ||
|2=nd | |2={{{{{|safesubst:}}}#ifeq:{{{2|}}}|d|d|nd}} | ||
|3=rd | |3={{{{{|safesubst:}}}#ifeq:{{{2|}}}|d|d|rd}} | ||
|th | |th | ||
}} | }} | ||
}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes | |||
}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes | |||
|</sup> | |</sup> | ||
}}<noinclude> | }}<noinclude> | ||
{{documentation}} | {{documentation}} | ||
</noinclude> | </noinclude> |
Revision as of 16:51, 21 March 2012
{{{1}}}th
This template uses Lua: |
This template is used on approximately 134,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
Usage
{{Ordinal|integer}}
This template will add the appropriate ordinal indicator to a given integer.
Use {{Ordinal|integer|sup=yes}}
to display the ordinal suffix in superscript. Do not use superscript notation in the article space, per this section of the Manual of Style.
For an integer ending in 1, 2 or 3 (except for integers ending in 11, 12 or 13), the ordinal suffix will be -st, -nd and -rd, respectively. To display -d for the ordinal suffix rather than -nd and -rd, use {{Ordinal|integer|d}}
.
This template should not be used in running prose in articles; it is intended for automated script processing of numeric data. Writing something like "in the {{ordinal|16}} century
" serves no purpose, and just makes the wikicode harder to understand and edit.
Examples
Code | Result |
---|---|
{{Ordinal|101}} |
101st |
{{Ordinal|−102}} |
−102nd |
{{Ordinal|102|sup=yes}} |
102nd |
{{Ordinal|103}} |
103rd |
{{Ordinal|103|d}} |
103d |
Other
- This template can be substituted.
See also
- {{Cardinal}}, which removes the ordinal indicator from an ordinal number
- {{Ordinal to word}}, which produces the spelled-out form, "first" "second", etc.