Mòdul:Wikidata: diferència entre les revisions
Contingut suprimit Contingut afegit
protecció a getSiteLink |
actualització, corr. títol i tractament dates |
||
Línia 1:
-- version
local p = {}
Línia 27:
[10] = "F Y", -- precision: month
[11] = "F j, Y", -- precision: day
["beforenow"] = "$1 BCE", -- how to format negative numbers for precisions 0 to 5
["afternow"] = "$1 CE", -- how to format positive numbers for precisions 0 to 5
["bc"] = '$1 "BCE"', -- how print negative years
["ad"] = "$1", -- how print
},
["monolingualtext"] = '<span lang="%language">%text</span>',
Linha 64 ⟶ 59:
{
langcode = mw.language.getContentLanguage().code,
module_title =
}
Linha 410 ⟶ 405:
-- Dates and times are stored in ISO 8601 format
local timestamp = data.time
local
local calendar_add = ""
if string.sub(timestamp, 1, 1) == '-' then
▲ addon = i18n.datetime["bc-addon"]
elseif string.sub(timestamp, 2, 3) == '00' then
else
-- calendar model
Linha 430 ⟶ 422:
end
end
local function d(f, t)
local ts = t or timestamp
local form = type(f) == "function" and f(ts) or f -- function in i18n.datetime[precision]
if string.sub(ts, 1, 1) == '-' then ts = '+' .. string.sub(ts, 2) end -- formatDate() only supports years from 0
return mw.language.new(parameters.lang[1]):formatDate(form, ts)
end
local function postFormat(t)
if post_format and mw.ustring.find(post_format, "$1") then
return mw.ustring.gsub(post_format, "$1", t)
end
return t
end
local precision = data.precision or 11
local intyear = tonumber(
local ret = ""
Linha 443 ⟶ 445:
local y2 = math.ceil(math.abs(intyear) / factor)
local relative = mw.ustring.gsub(i18n.datetime[precision], "$1", tostring(y2))
if
ret = mw.ustring.gsub(i18n.datetime.beforenow, "$1", relative)
else
Linha 456 ⟶ 457:
local card = math.floor((intyear - 1) / 1000) + 1
if mw.ustring.find(i18n.datetime[6], "$1") then
ret = mw.ustring.gsub(i18n.datetime[6], "$1", tostring(card))
else
ret = d(i18n.datetime[6], string.format("%04d", tostring(card)))
end
ret = postFormat(ret)
elseif precision == 7 then -- centuries
local card = math.floor((math.abs(intyear) - 1) / 100) + 1
if mw.ustring.find(i18n.datetime[7], "$1") then
ret = mw.ustring.gsub(i18n.datetime[7], "$1", tostring(card))
else
ret = d(i18n.datetime[7], string.format("%04d", tostring(card)))
end
ret = postFormat(ret) .. calendar_add
elseif precision == 8 then -- decades
local card = math.floor(math.abs(intyear) / 10) * 10
ret = postFormat(mw.ustring.gsub(i18n.datetime[8], "$1", tostring(card))
elseif
ret = postFormat(tostring(intyear)
elseif precision == 10 then -- month
timestamp = timestamp .. " + 1 day" -- formatDate yyyy-mm-00 returns the previous month
ret
ret = postFormat(ret) .. calendar_add
ret, _ = string.gsub(
else -- precision 11, day
ret
ret = postFormat(ret) .. calendar_add
ret, _ = string.gsub(ret, "([ %[])0+", "%1")
end
return ret,
end
Linha 847 ⟶ 852:
local showerrors = args["showerrors"]
local default = args["default"]
if default then showerrors = nil end▼
local editicon = not (args.editicon == "false" or args.editicon == "no")
Linha 887 ⟶ 893:
blacklist, blacklisted = setWhiteOrBlackList("blacklist", #qualifierId, args)
end
▲ if default then showerrors = nil end
-- fetch property
|