Module:DateTitleList:修订间差异
跳转到导航
跳转到搜索
创建页面,内容为“local p = {} -- 格式化日期和生成链接 local function formatDate(date, title, year, baseYear) local dateYear = string.sub(date, 1, 4) local monthDay = os.date("%m月%d日", os.time{year=string.sub(date, 1, 4), month=string.sub(date, 5, 6), day=string.sub(date, 7, 8)}) local categoryLink = "" .. monthDay .. "" local pageLink = "[[直播记录/vedal987频道/" .. dateYear .. "年" .. monthDay .. "|" .. tit…” |
无编辑摘要 |
||
第1行: | 第1行: | ||
local function formatDate(date, title, year, baseYear) | local function formatDate(date, title, year, baseYear) | ||
local dateYear = string.sub(date, 1, 4) | local dateYear = string.sub(date, 1, 4) -- 获取年份 | ||
local monthDay = os.date("%m月%d日", os.time{year= | local monthDay = os.date("%m月%d日", os.time{ | ||
local categoryLink = "[[:Category: | year = tonumber(dateYear), | ||
month = tonumber(string.sub(date, 5, 6)), | |||
day = tonumber(string.sub(date, 7, 8)) | |||
}) | |||
-- 构造分类链接 | |||
local categoryLink = '<span class="date-link">[[:Category:' .. monthDay .. '|' .. monthDay .. ']]</span>' | |||
-- | -- 如果年份不同于baseYear,添加小号年份 | ||
if dateYear ~= baseYear then | if dateYear ~= baseYear then | ||
categoryLink = "[[:Category: | categoryLink = '<span class="date-link">[[:Category:' .. monthDay .. '|{{ruby|' .. monthDay .. '|<span class="small-year">' .. dateYear .. '年</span>}}]]</span>' | ||
end | end | ||
-- 构造页面链接 | |||
local pageLink = "[[直播记录/vedal987频道/" .. dateYear .. "年" .. monthDay .. "|" .. title .. "]]" | |||
return "* '''" .. categoryLink .. "''' " .. pageLink | return "* '''" .. categoryLink .. "''' " .. pageLink | ||
end | end | ||
2025年1月23日 (四) 00:35的版本
此模块的文档可以在Module:DateTitleList/doc创建
local function formatDate(date, title, year, baseYear)
local dateYear = string.sub(date, 1, 4) -- 获取年份
local monthDay = os.date("%m月%d日", os.time{
year = tonumber(dateYear),
month = tonumber(string.sub(date, 5, 6)),
day = tonumber(string.sub(date, 7, 8))
})
-- 构造分类链接
local categoryLink = '<span class="date-link">[[:Category:' .. monthDay .. '|' .. monthDay .. ']]</span>'
-- 如果年份不同于baseYear,添加小号年份
if dateYear ~= baseYear then
categoryLink = '<span class="date-link">[[:Category:' .. monthDay .. '|{{ruby|' .. monthDay .. '|<span class="small-year">' .. dateYear .. '年</span>}}]]</span>'
end
-- 构造页面链接
local pageLink = "[[直播记录/vedal987频道/" .. dateYear .. "年" .. monthDay .. "|" .. title .. "]]"
return "* '''" .. categoryLink .. "''' " .. pageLink
end