local p = {}
local yesno = require('Module:Yesno')
local suffixes = {
"ci", "ci", "cü", "cü", "ci", "cı", "ci", "ci", "cu", [0] = "cu", [10] = "cu", [20] = "ci",
[30] = "cu", [40] = "cı", [50] = "ci", [60] = "cı", [70] = "ci", [80] = "ci", [90] = "cı"
}
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 = "ci"
if x then
local mod10 = math.abs(x) % 10
local mod100 = math.abs(x) % 100
local mod1000 = math.abs(x) % 1000
if x == 0 then
suffix = "cı"
elseif mod1000 == 0 then
suffix = "ci"
elseif mod100 == 0 then
suffix = "cü"
elseif mod10 == 0 then
suffix = suffixes[x % 100]
else
suffix = suffixes[x %10] or ""
end
end
if sup then
suffix = "<sup>" .. suffix .. "</sup>"
end
return n .. '-' .. suffix
end
-- Global inYear function
function inYear( year )
if year >= 0 then
return p._ordinal(year)
else
year = -year
return 'e.ə. ' .. p._ordinal(year)
end
end
function makeOrdinal( year )
return p._ordinal(year)
end
-- Global checkApril function
function checkApril(elseThanApril, displaySuffixMonth)
if (elseThanApril == 4 or elseThanApril == '[Aa]prel') then
return displaySuffixMonth .. 'də'
else
return displaySuffixMonth .. 'da'
end
end
return p