跳到内容

Module:ConvertLink:修订间差异

添加308字节 、​ 2024年8月10日 (星期六)
无编辑摘要
(修复剧情名义谱师跳转问题)
无编辑摘要
第218行: 第218行:


local lang, VT
local lang, VT
local function findVer(ver, date)
lang = lang or mw.language.getContentLanguage()
-- VT = VT or mw.loadJsonData 'Template:VersionTime.json'
VT = VT or mw.text.jsonDecode(mw.title.new('Template:VersionTime.json'):getContent())
local ymd = tonumber(lang:formatDate('ymd', '@' .. date)) - 1
local vt
if VT[ver] then vt=VT[ver] else return ver, ymd end
local dates = vt.time
local version = vt.ver
if #dates ~= #version then return ver,ymd end
local l, r = 1, #dates
while l < r do
local m = math.floor((l + r) / 2)
if dates[m] < ymd then
l = m + 1
else
r = m
end
end
return ver.. '.' ..version[l], dates[l]
end
local function dateConvert(date)
if not date then return nil end
local dateStr = tostring(date)
local yy = string.sub(dateStr,1,2)
local mm = string.sub(dateStr,3,4)
local dd = string.sub(dateStr,5,6)
return '20'..string.format("%02d/%02d/%02d", yy, mm, dd % 100)
end
function p.fullVersionNum(ver, date)
function p.fullVersionNum(ver, date)
local verClass = math.floor(date/100)
local verClass = math.floor(date/100)
local verData = getMemory('ver', verClass)
local verData = getMemory('ver', verClass)
if verData then return verData[1], verData[2], 'Memory' end
if verData then return verData[1], verData[2], 'Memory' end
local function findVer()
lang = lang or mw.language.getContentLanguage()
-- VT = VT or mw.loadJsonData 'Template:VersionTime.json'
VT = VT or mw.text.jsonDecode(mw.title.new('Template:VersionTime.json'):getContent())
local ymd = tonumber(lang:formatDate('ymd', '@' .. date)) - 1
local vt
if VT[ver] then vt=VT[ver] else return ver, ymd end
local dates = vt.time
local version = vt.ver
if #dates ~= #version then return ver,yml end
local l, r = 1, #dates
while l < r do
local m = math.floor((l + r) / 2)
if dates[m] < ymd then
l = m + 1
else
r = m
end
end
return ver.. '.' ..version[l], dates[l]
end
verData={}
verData={}
verData[1], verData[2] = findVer()
verData[1], verData[2] = findVer(ver, date)
verData[2] = dateConvert(verData[2])
memory.ver[verClass] = verData
memory.ver[verClass] = verData
return verData[1], verData[2]
return verData[1], verData[2]
956

个编辑