Difference between revisions of "Template:ordinal"
Firestar233 (talk | contribs) m |
Firestar233 (talk | contribs) (i won't be needing this anymore) |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | <includeonly>{{formatnum: {{#expr: {{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}} }} |{{#if:{{#pos:{{{2|}}}|R}}|R}} }}{{#if:{{#pos:{{{2|}}}|S}}||<sup>}}{{#ifexpr:10<=abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100 and abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100<=20|th|{{#switch:{{#expr:abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 10}}|1=st|2=nd|3=rd|th}}}}{{#if:{{#pos:{{{2|}}}|S}}||</sup>}}</includeonly><noinclude> | + | <includeonly>{{formatnum: {{#expr: {{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}} }} |{{#if:{{#pos:{{{2|}}}|R}}|R}} }}{{#if:{{#pos:{{{2|}}}|S}}||<sup>}}{{#ifexpr:10<=floor(abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}})) mod 100 and floor(abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}})) mod 100<=20|th|{{#switch:{{#expr:floor(abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}})) mod 10}}|1=st|2=nd|3=rd|th}}}}{{#if:{{#pos:{{{2|}}}|S}}||</sup>}}</includeonly><noinclude> |
This properly formats the given number as an abbreviated ordinal number in English. | This properly formats the given number as an abbreviated ordinal number in English. | ||
===Usage=== | ===Usage=== | ||
| − | <code><nowiki>{{ordinal|number[|flags]}} | + | <code><nowiki>{{ordinal|</nowiki>'''number'''[|'''''flags'''(optional)'']}}</code> |
*'''<code>number</code>''' is the number to be formatted | *'''<code>number</code>''' is the number to be formatted | ||
*:- Negative numbers get formatted as positive numbers with an negative sign added to the front of the number. | *:- Negative numbers get formatted as positive numbers with an negative sign added to the front of the number. | ||
*:- 0 gets formatted as "Zeroth". | *:- 0 gets formatted as "Zeroth". | ||
*'''<code>flags</code>''' indicates flags for the format of the output | *'''<code>flags</code>''' indicates flags for the format of the output | ||
| − | *:- If "<code>R</code>" is in <code>flags</code>, the output is formatted without commas. | + | *:- If "<code>R</code>" is in '''<code>flags</code>''', the output is formatted without commas. |
| − | *:- If "<code>S</code>" is in <code>flags</code>, the output is formatted with the ordinal indicators not in superscripts. | + | *:- If "<code>S</code>" is in '''<code>flags</code>''', the output is formatted with the ordinal indicators not in superscripts. |
*:- Flags can be combined in any order. | *:- Flags can be combined in any order. | ||
*:- If '''<code>flags</code>''' is omitted, the output is formatted as if no flags were given. | *:- If '''<code>flags</code>''' is omitted, the output is formatted as if no flags were given. | ||
| Line 42: | Line 42: | ||
:: produces | :: produces | ||
: <code>{{ordinal|-271828|RS}}</code> | : <code>{{ordinal|-271828|RS}}</code> | ||
| + | * <code><nowiki>{{ordinal}} <!-- not recommended --></nowiki></code> | ||
| + | :: produces | ||
| + | : <code>{{ordinal}}</code> | ||
{| class = "wikitable" | {| class = "wikitable" | ||
| − | |+ | + | |+ First 29 ordinal numbers in English |
|- | |- | ||
! Number !! Ordinal !! Number !! Ordinal !! Number !! Ordinal | ! Number !! Ordinal !! Number !! Ordinal !! Number !! Ordinal | ||
| Line 88: | Line 91: | ||
|29 ||29th | |29 ||29th | ||
|} | |} | ||
| + | [[Category: Templates]] | ||
| + | </noinclude> | ||
Latest revision as of 01:14, 24 April 2025
This properly formats the given number as an abbreviated ordinal number in English.
Usage[edit]
{{ordinal|number[|flags(optional)]}}
numberis the number to be formatted- - Negative numbers get formatted as positive numbers with an negative sign added to the front of the number.
- - 0 gets formatted as "Zeroth".
flagsindicates flags for the format of the output- - If "
R" is inflags, the output is formatted without commas. - - If "
S" is inflags, the output is formatted with the ordinal indicators not in superscripts. - - Flags can be combined in any order.
- - If
flagsis omitted, the output is formatted as if no flags were given.
- - If "
Examples[edit]
-
{{ordinal|1}}
- produces
-
1st
-
{{ordinal|0002}}
- produces
-
2nd
-
{{ordinal|0}}
- produces
-
0th
-
{{ordinal|-00003}}
- produces
-
-3rd
-
{{ordinal|123456789}}
- produces
-
123,456,789th
-
{{ordinal|983,675,911}}
- produces
-
983,675,911th
-
{{ordinal|123456|S}}
- produces
-
123,456th
-
{{ordinal|00,314,159|R}}
- produces
-
314159th
-
{{ordinal|-271828|RS}}
- produces
-
-271828th
-
{{ordinal}} <!-- not recommended -->
- produces
-
0th
| Number | Ordinal | Number | Ordinal | Number | Ordinal |
|---|---|---|---|---|---|
| 0 | 0th | 10 | 10th | 20 | 20th |
| 1 | 1st | 11 | 11th | 21 | 21st |
| 2 | 2nd | 12 | 12th | 22 | 22nd |
| 3 | 3rd | 13 | 13th | 23 | 23rd |
| 4 | 4th | 14 | 14th | 24 | 24th |
| 5 | 5th | 15 | 15th | 25 | 25th |
| 6 | 6th | 16 | 16th | 26 | 26th |
| 7 | 7th | 17 | 17th | 27 | 27th |
| 8 | 8th | 18 | 18th | 28 | 28th |
| 9 | 9th | 19 | 19th | 29 | 29th |
