Kontent qismiga oʻtish

Modul:Ordinal

Vikipediya, ochiq ensiklopediya

Bu modul uchun Modul:Ordinal/doc nomli hujjat sahifasini yaratishingiz mumkin

-- Ordinals for Azerbaijani by RexxS
-- Takes a number and returns its ordinal.

local suffixes = {
	"-", "-", "-", "-", "-", "-", "-", "-", "-", [0] = "-", [10] = "-", [20] = "-",
	[30] = "-", [40] = "-", [50] = "-", [60] = "-", [70] = "-", [80] = "-", [90] = "-"
}

function ordinal(number)
	local suffix
	if number == 0 then
		suffix = "-"
	elseif number % 1000 == 0 then
		suffix = "-"
	elseif number %100 == 0 then
		suffix = "-"
	elseif number %10 == 0 then
		suffix = suffixes[number % 100]
	else
		suffix = suffixes[number %10] or ""
	end
	return number .. "-" .. suffix
end

-- Global inYear function
function inYear( year )
	if year >= 0 then
    	return ordinal(year)
	else
    	year = -year
    return 'e.ə. ' .. ordinal(year) 
		end
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

-- Just for testing by allowing a #invoke: call
p = {}

function p.Ordinal(frame)
	number = tonumber(frame.args[1] or frame.args.number) or 0
	return ordinal(number)
end

return p