Modül:Tarih
Bu modül için bir Modül:Tarih/belge belgelendirmesi oluşturabilirsiniz
local getArgs = require('Module:Bağımsız değişkenler').getArgs
local yesno = require('Module:Yesno')
local lang = mw.getContentLanguage()
local p = {}
-- Do not replace the following with a variation of #ifexist. This is an expensive parser function that should not be used for this module.
local year_articles = { -- When an article is created for a specific year, add it to the list. Don't forget the negative sign for BC!
[1] = true,
[2] = true,
[4] = true,
[5] = true,
[9] = true,
[10] = true,
[12] = true,
[13] = true,
[37] = true,
[39] = true,
[41] = true,
[42] = true,
[43] = true,
[44] = true,
[45] = true,
[47] = true,
[48] = true,
[49] = true,
[50] = true,
[51] = true,
[52] = true,
[54] = true,
[56] = true,
[59] = true,
[60] = true,
[61] = true,
[83] = true,
[92] = true,
[99] = true,
[100] = true,
[101] = true,
[103] = true,
[104] = true,
[105] = true,
[106] = true,
[111] = true,
[120] = true,
[127] = true,
[128] = true,
[129] = true,
[130] = true,
[131] = true,
[132] = true,
[133] = true,
[134] = true,
[135] = true,
[136] = true,
[160] = true,
[161] = true,
[184] = true,
[196] = true,
[209] = true,
[211] = true,
[212] = true,
[219] = true,
[233] = true,
[236] = true,
[259] = true,
[260] = true,
[261] = true,
[262] = true,
[280] = true,
[281] = true,
[282] = true,
[283] = true,
[284] = true,
[285] = true,
[289] = true,
[290] = true,
[295] = true,
[297] = true,
[298] = true,
[299] = true,
[300] = true,
}
local function is_empty(s)
return s == nil or s == ''
end
function p.link(year, suffix)
local s, name, page
if year > 0 then
s = lang:formatNum(year)
name = suffix and ("AC " .. s) or s
if year_articles[year] then
page = mw.title.makeTitle(0, "AC " .. s)
else
page = mw.title.makeTitle(
0,
"Years after Aegon's Conquest",
"Year AC " .. s
)
end
elseif year < 0 then
s = lang:formatNum(math.abs(year))
name = suffix and ("BC " .. s) or s
if year_articles[year] then
page = mw.title.makeTitle(0, "BC " .. s)
else
page = mw.title.makeTitle(
0,
"Years before Aegon's Conquest",
"Year BC " .. s
)
end
end
return "[[" .. page.fullText .. "|" .. name .. "]]"
end
function p.nolink(year, suffix)
local s = tostring(year)
if year > 0 then
return suffix and ("AC " .. s) or s
elseif year < 0 then
s = tostring(math.abs(year))
return suffix and ("BC " .. s) or s
end
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local y1 = lang:parseFormattedNumber(args[1])
local y2 = lang:parseFormattedNumber(args[2])
local suffix = yesno(args.suffix)
if suffix == nil then suffix = true end
if y1 == nil then
local text = args[1]
return "[[Years after Aegon's Conquest|" .. text .. " AC]]"
elseif y2 == nil then
if args[2] == '+' then
return p.link(y1, true) .. " – Present"
else
return p.link(y1, suffix)
end
elseif (y1 > 0) == (y2 > 0) then
return p.link(y1, false) .. "–" .. p.link(y2, true)
else
return p.link(y1, true) .. " – " .. p.link(y2, true)
end
end
function p._format(d)
return tonumber(d) and p._main{d} or d
end
return p