Template talk:Ordinal/Archive 1

Latest comment: 8 years ago by Jimp in topic Superscripting


More efficient and more "correct" code?

edit

{{edit protected}} The following code might be more efficient and match the actual data problem better:

{{#switch:{{#expr:{{{1}}} mod 100}}
|11|12|13=th
|{{#switch:{{#expr:{{{1}}} mod 10}}
|1=st
|2=nd
|3=rd
|th
}}
}}

Peet Ern (talk) 02:50, 16 December 2008 (UTC)Reply

I agree. JIMp talk·cont 10:38, 18 December 2008 (UTC)Reply
Done. --- RockMFR 06:20, 22 December 2008 (UTC)Reply

Edit request

edit

{{editprotected}} Please update {{/doc}} with {{documentation}}. Per Wikipedia:Template documentation/List Thankyou. -- αŁʰƏЩ @ 06:03, 28 April 2008 (UTC)Reply

Done. – Luna Santin (talk) 08:34, 28 April 2008 (UTC)Reply

Edit request

edit

{{editprotected}}

There is a bug in this template; it inserts a space after its number in the default form. I have not checked the 'd' option. — Preceding unsigned comment added by 24.216.255.230 (talk)

I see that you recently edited Countdown with Keith Olbermann, which did have an erroneous space related to use of this template; however, the problem appears to have been caused by formatting at the article, which I believe I've fixed by removing a particular space, there. Is this problem duplicated anywhere else, or does it persist that I'm not aware of? – Luna Santin (talk) 11:19, 15 July 2008 (UTC)Reply

Edit request

edit

{{editprotected}} Could we replace this:

<includeonly>{{{1}}}{{ {{{|safesubst:}}}Ordinal/{{{2|}}}th|{{{1}}}}}</includeonly>

with this:?

<includeonly>{{{1|}}}{{#if:{{{sup|}}}|<sup>|}}{{#switch:{{#expr: {{{1|}}} mod 100}}|11|12|13=th|#default={{#switch:{{#expr: {{{1|}}} mod 10}}|1=st|2={{#if:{{{d|}}}||n}}d|3={{#if:{{{d|}}}||r}}d|#default=th}}{{#if:{{{sup|}}}|</sup>|}}</includeonly>

It adds a superscript parameter, and the wikicode makes a lot more sense than all of the subpages and safesubsts. Samwb123T-C-E 19:19, 10 July 2010 (UTC)Reply

  Done, ping my talk page if there are any issues. HJ Mitchell | Penny for your thoughts? 23:15, 10 July 2010 (UTC)Reply
This edit has been reverted. It broke all pages that use {{Day}}, which uses this as a meta-template. Zzyzx11 (talk) 23:47, 10 July 2010 (UTC)Reply
The actual template that seemed to be affected was {{Day/nth day}}, as {{Day}} takes the page name of each day of the week page (i.e January 1) and calls Day/nth day. Zzyzx11 (talk) 00:01, 11 July 2010 (UTC)Reply
Well then fix {{Day/nth day}} if you have to. Really, I don't see what problem this would cause, but we can fix whatever problem it causes. Samwb123T-C-E 02:47, 11 July 2010 (UTC)Reply
The syntax in your code was incorrect. Please do not request changes to widely used templates without thoroughly testing them first. — Martin (MSGJ · talk) 08:19, 11 July 2010 (UTC)Reply

Edit request (revised)

edit

{{editprotected}}

OK. From the previous discussion, I saw that I had some problems with my wikimarkup. Well, I have tested it out now, and I think it works! With this code, both

{{Ordinal|23|d|sup}}

and

{{Ordinal|23|sup|d}}

will produce 23d. Test it out for yourself, and see if there are any problems (however I don't believe there are any). Here it is:

{{{1|}}}{{#ifeq:{{{2|}}}|sup|<sup>|{{#ifeq:{{{3|}}}|sup|<sup>|}}}}{{#switch:{{#expr: {{{1|}}} mod 100}}|11|12|13=th|#default={{#switch:{{#expr: {{{1|}}} mod 10}}|1=st|2={{#ifeq:{{{2|}}}|d||{{#ifeq:{{{3|}}}|d||n}}}}d|3={{#ifeq:{{{2|}}}|d||{{#ifeq:{{{3|}}}|d||r}}}}d|#default=th}}}}{{#ifeq:{{{2|}}}|sup|</sup>|{{#ifeq:{{{3|}}}|sup|</sup>|}}}}

Please consider changing Template:Ordinal to this code. It makes a lot more sense than all of the safesubsts. Thanks! Samwb123T-C-E 17:55, 11 July 2010 (UTC)Reply

"safesubst" is to allow the template to be substituted cleanly (see Help:Safesubst). I don't see how your code allows for that. — Martin (MSGJ · talk) 18:20, 11 July 2010 (UTC)Reply
Well, then how about we move this code to a subpage, then safesubst that subpage? Still, it makes a lot more sense than all of the current subpages. Samwb123T-C-E 18:44, 11 July 2010 (UTC)Reply
I've had a look at what you are trying to do. I agree that doing away with the subpages would be simpler. I would recommend against using an unnumbered parameter for the "sup" feature as it makes the code much more complicated. It would be better to use the named parameter |sup=. I've put some code in /sandbox and examples on /testcases - would you like to have a look? All the safesubsts are necessary to make it possible to substitute this template. By the way, you can stop using {{editprotected}} now - I've got this watchlisted. — Martin (MSGJ · talk) 20:31, 11 July 2010 (UTC)Reply
That works! Samwb123T-C-E 20:40, 11 July 2010 (UTC)Reply
One question: is the "d" notation ever used with a subscript? If not, we should take that option away. — Martin (MSGJ · talk) 20:59, 11 July 2010 (UTC)Reply

I'm not sure. I've looked all over... I'll try the reference desk. Samwb123T-C-E 21:37, 11 July 2010 (UTC)Reply

I've updated the template. I notice you were directed towards Wikipedia:Manual of Style (dates and numbers)#Typography. In light of that, when you update the documentation, could you clarify that this feature is not to be used in article space? — Martin (MSGJ · talk) 10:17, 12 July 2010 (UTC)Reply

Negative Ordinals

edit

{{editprotected}} It's probably not a big deal, but can I suggest we change the template ever so slightly to handle negative numbers correctly? To do this, just change the two occurrences of:

#expr:{{{1}}}

to

#expr:abs({{{1}}})

As it stands now, calls such as {{Ordinal|-1}} are handled poorly: -1stRobinHood70 (talkcontribs) 22:32, 26 July 2010 (UTC)Reply

  Done — Martin (MSGJ · talk) 05:30, 27 July 2010 (UTC)Reply

d

edit

Current code is

{{{1}}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |<sup>
}}{{{{{|safesubst:}}}#ifeq:{{{2}}}|d
 |d
 |{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs({{{1}}}) mod 100}}
  |11|12|13=th
  |{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs{{{1}}} mod 10}}
   |1=st
   |2=nd
   |3=rd
   |th
  }}
 }}
}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |</sup>
}}

but should be

{{{1}}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |<sup>
}}{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs({{{1}}}) mod 100}}
  |11|12|13=th
  |{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs{{{1}}} mod 10}}
   |1=st
   |2={{{2|nd}}}
   |3={{{2|rd}}}
   |th
  }}
 }}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |</sup>
}}

The current version uses "d" automatically if the second parameter is d, even if the first parameter is 1 or something. The proposed version uses "d" only for numbers for which it should be used. However, the proposed vrsion does no sanity check to make sure the scond parameter is what it should be. So perhaps the following would be better:

{{{1}}}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |<sup>
}}{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs({{{1}}}) mod 100}}
  |11|12|13=th
  |{{{{{|safesubst:}}}#switch:{{{{{|safesubst:}}}#expr:abs{{{1}}} mod 10}}
   |1=st
   |2={{#ifeq:{{{2|}}}|d|d|nd}}
   |3={{#ifeq:{{{2|}}}|d|d|rd}}
   |th
  }}
 }}{{{{{|safesubst:}}}#ifeq:{{{sup}}}|yes
 |</sup>
}}

Note that I have not tested this code.—msh210 19:15, 16 March 2012 (UTC)Reply

  Not done. Please test the code in the Ordinal/sandbox and re-request.  An optimist on the run! 08:17, 18 March 2012 (UTC)Reply
Tested. Re-transcluding {{editprotected}}, above.—msh210 22:05, 19 March 2012 (UTC)Reply
  Done Tra (Talk) 16:53, 21 March 2012 (UTC)Reply
Thanks.—msh210 19:18, 21 March 2012 (UTC)Reply

Stripping ordinals?

edit

Odd question, is there a way to have a template that strips the ordinal suffix from an existing ordinal number, such as a pagename which uses an ordinal number? Lestatdelc (talk) 07:23, 11 January 2013 (UTC)Reply

Done: see {{cardinal}}. – Minh Nguyễn (talk, contribs) 07:04, 4 October 2013 (UTC)Reply

Feature Request

edit

Would it be possible to add a feature to have the template spell out the ordinal number in full? For instance, if I were to write {{ordinal|1|spell=yes}} for instance, I'd like it to be able to be spelled out as first. I know {{convert}} has a feature like this and hope this template can be modified do the same for standardization's sake.

Cheers,

The Obento Musubi (talk) 08:55, 18 March 2015 (UTC)Reply

I back this request. @The Obento Musubi: Turns out, that particular template already actually exists - {{Ordinal to word}} Alex|The|Whovian 11:58, 26 June 2015 (UTC)Reply

Superscripting

edit

Why is superscripting supported anyway? It's not used on articlespace, so is this genuinely something we want to encourage on other namespaces? Chris Cunningham (user:thumperward: not at work) - talk 09:28, 8 September 2010 (UTC)Reply

It should be removed per WP:ORDINAL. Jimp 03:40, 23 November 2016 (UTC)Reply