<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AOrdinal</id>
	<title>模块:Ordinal - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.statsape.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AOrdinal"/>
	<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:Ordinal&amp;action=history"/>
	<updated>2026-04-03T22:58:31Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:Ordinal&amp;diff=1537&amp;oldid=prev</id>
		<title>Zeroclanzhang：​创建页面，内容为“--     This template will add the appropriate ordinal suffix to a given integer.   Please do not modify this code without applying the changes first at Module:Ordinal/sandbox and testing.     local p = {}  local yesno     = require(&#039;Module:Yesno&#039;) -- boolean value interpretation  --[[ This function converts an integer value into a numeral followed by ordinal indicator. The output string might contain HTML tags.   Usage: {{#invoke:Ordinal|ordinal|1=|2=|sup=}…”</title>
		<link rel="alternate" type="text/html" href="https://wiki.statsape.com/index.php?title=%E6%A8%A1%E5%9D%97:Ordinal&amp;diff=1537&amp;oldid=prev"/>
		<updated>2023-08-09T16:01:30Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“--&lt;a href=&quot;/index.php?title=This_template_will_add_the_appropriate_ordinal_suffix_to_a_given_integer._Please_do_not_modify_this_code_without_applying_the_changes_first_at_Module:Ordinal/sandbox_and_testing.&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;This template will add the appropriate ordinal suffix to a given integer. Please do not modify this code without applying the changes first at Module:Ordinal/sandbox and testing.（页面不存在）&quot;&gt;This template will add the appropriate ordinal suffix to a given integer.   Please do not modify this code without applying the changes first at Module:Ordinal/sandbox and testing.   &lt;/a&gt;  local p = {}  local yesno     = require(&amp;#039;Module:Yesno&amp;#039;) -- boolean value interpretation  --[[ This function converts an integer value into a numeral followed by ordinal indicator. The output string might contain HTML tags.   Usage: {{#invoke:Ordinal|ordinal|1=|2=|sup=}…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
 &lt;br /&gt;
This template will add the appropriate ordinal suffix to a given integer.&lt;br /&gt;
 &lt;br /&gt;
Please do not modify this code without applying the changes first at&lt;br /&gt;
Module:Ordinal/sandbox and testing.&lt;br /&gt;
 &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local yesno     = require(&amp;#039;Module:Yesno&amp;#039;) -- boolean value interpretation&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
This function converts an integer value into a numeral followed by ordinal indicator.&lt;br /&gt;
The output string might contain HTML tags.&lt;br /&gt;
 &lt;br /&gt;
Usage:&lt;br /&gt;
{{#invoke:Ordinal|ordinal|1=|2=|sup=}}&lt;br /&gt;
{{#invoke:Ordinal|ordinal}} - uses the caller&amp;#039;s parameters&lt;br /&gt;
 &lt;br /&gt;
Parameters&lt;br /&gt;
    1: Any number or string.&lt;br /&gt;
    2: Set to &amp;quot;d&amp;quot; if the module should display &amp;quot;d&amp;quot; instead of &amp;quot;nd&amp;quot; and &amp;quot;rd&amp;quot;.&lt;br /&gt;
    sup: Set to yes/no to toggle superscript ordinal suffix.&lt;br /&gt;
]]&lt;br /&gt;
function p.ordinal(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
    if args[1] == nil then&lt;br /&gt;
        args = frame:getParent().args&lt;br /&gt;
    end&lt;br /&gt;
    if args[1] == nil then&lt;br /&gt;
    	args[1] = &amp;quot;{{{1}}}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    return p._ordinal(args[1], (args[2] == &amp;#039;d&amp;#039;), yesno(args.sup))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._ordinal(n, d, sup)&lt;br /&gt;
	local x = tonumber(mw.ustring.match(n, &amp;quot;(%d*)%W*$&amp;quot;))&lt;br /&gt;
	local suffix = &amp;quot;th&amp;quot;&lt;br /&gt;
	-- If tonumber(n) worked:&lt;br /&gt;
	if x then&lt;br /&gt;
		local mod10 = math.abs(x) % 10&lt;br /&gt;
		local mod100 = math.abs(x) % 100&lt;br /&gt;
		if     mod10 == 1 and mod100 ~= 11 then&lt;br /&gt;
			suffix = &amp;quot;st&amp;quot;&lt;br /&gt;
		elseif mod10 == 2 and mod100 ~= 12 then&lt;br /&gt;
			if d then suffix = &amp;quot;d&amp;quot; else suffix = &amp;quot;nd&amp;quot; end&lt;br /&gt;
		elseif mod10 == 3 and mod100 ~= 13 then&lt;br /&gt;
			if d then suffix = &amp;quot;d&amp;quot; else suffix = &amp;quot;rd&amp;quot; end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if sup then&lt;br /&gt;
		suffix = &amp;quot;&amp;lt;sup&amp;gt;&amp;quot; .. suffix .. &amp;quot;&amp;lt;/sup&amp;gt;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	return n .. suffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zeroclanzhang</name></author>
	</entry>
</feed>