Module:DateTitleList:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local function format_date(date_str, title, year) | |||
local function | local year_in_date = string.sub(date_str, 1, 4) | ||
local | local month_day = os.date("%m月%d日", os.time{year=string.sub(date_str, 1, 4), month=string.sub(date_str, 5, 6), day=string.sub(date_str, 7, 8)}) | ||
local | local category_link = string.format("[[:Category:%s|%s]]", month_day, month_day) | ||
if year_in_date ~= year then | |||
category_link = string.format("[[:Category:%s|%s{{ruby|%s|''%s年''}}]]", month_day, month_day, year_in_date) | |||
if | |||
end | end | ||
local page_link = string.format("[[直播记录/vedal987频道/%s年%s|%s]]", year_in_date, month_day, title) | |||
local | return string.format("* '''%s''' %s", category_link, page_link) | ||
end | |||
return "* ''' | |||
local function compare_dates(a, b) | |||
return a.date < b.date | |||
end | end | ||
function p.main(frame) | |||
function p. | |||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local year = args.year or os.date("%Y") | local year = args.year or os.date("%Y") | ||
local entries = {} | local entries = {} | ||
for i = 1, 7 do | for i = 1, 7 do | ||
local date = args["date" .. i] | local date = args["date" .. i] | ||
第38行: | 第30行: | ||
end | end | ||
end | end | ||
table.sort(entries, compare_dates) | |||
table.sort(entries, | |||
local result = {} | |||
local | |||
for _, entry in ipairs(entries) do | for _, entry in ipairs(entries) do | ||
table.insert( | table.insert(result, format_date(entry.date, entry.title, year)) | ||
end | end | ||
return table.concat( | return table.concat(result, "\n") | ||
end | end | ||
return p | return p |