Ordinal

Documentation for this module may be created at मोड्युल:Ordinal/doc

--[[     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 at Module:Ordinal/sandbox/testcases and Module talk:Ordinal/sandbox/testcases.   ]]  local p = {}  local yesno     = require('Module:Yesno') -- 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=}} {{#invoke:Ordinal|ordinal}} - uses the caller's parameters   Parameters     1: Any number or string.     2: Set to "d" if the module should display "d" instead of "nd" and "rd".     sup: Set to yes/no to toggle superscript ordinal suffix. ]] function p.ordinal(frame) local args = frame.args     if args[1] == nil then         args = frame:getParent().args     end     if args[1] == nil then     args[1] = "{{{1}}}"     end     return p._ordinal(args[1], (args[2] == 'd'), yesno(args.sup)) end  function p._ordinal(n, d, sup) local x = tonumber(mw.ustring.match(n, "(%d*)%W*$")) local suffix = "th" -- If tonumber(n) worked: if x then local mod10 = math.abs(x) % 10 local mod100 = math.abs(x) % 100 if     mod10 == 1 and mod100 ~= 11 then suffix = "st" elseif mod10 == 2 and mod100 ~= 12 then if d then suffix = "d" else suffix = "nd" end elseif mod10 == 3 and mod100 ~= 13 then if d then suffix = "d" else suffix = "rd" end end end if sup then suffix = "" .. suffix .. "" end return n .. suffix end  return p 

Tags:

🔥 Trending searches on Wiki डोटेली:

कोलम्बोलेडी गागाअजय क्षेत्रीसीमा बिस्वासयुनाइटेड टेलिकमफिल्मफेयर पुरस्कारमनिलानेपाल क्रिकेट संघसतासीधाममिरेन्डा कसग्रोभबेयोन्सेअरुण नदीभ्लादिमिर पुटिनदक्ष प्रजापतिघानाकन्काई नगरपालिकाल्वाङकसानिभैरव अर्यालचक्रवर्ती राजगोपालाचारीदिनेश डिसीकतारक्युबारवी गिरीकर्णाली पुलसुर्खेत जिल्लामंगल बहुमुखी क्याम्पससीवाईसी अत्तरियादैलेख जिल्लागौरीशंकर संरक्षण क्षेत्रविक्रम (अभिनेता)इनर्वा, धनुषालोकतान्त्रिक गणतन्त्र कंगोप्रथम विश्वयुद्धबाइबलरकुल प्रीत सिंहघडीफूलअखिल नेपाल राष्ट्रिय स्वतन्त्र विद्यार्थी युनियनदक्षिण अमेरिकाकेपटाउनमालकोटकङ्गना राणावतऋतुसुर्मा सरोवर जाँतधमेना गाउँ विकास समितीअन्टार्क्टिकाचूरेभावर राष्ट्रिय एकता पार्टी नेपालजर्मनीकैलाली जिल्लाअंकाअफ्रिकाधौलाकोट गाविसश्रीलंकानोबेल शान्ति पुरस्कारकम्बोडियाबकधुवा गाविसरूख कमलश्रीमद्भगवद गीतावर्षा🡆 More