加帕里图书馆 - 兽娘动物园中文维基
动物朋友 けものフレンズ KemonoFriends百科
模块:历史事件:修订间差异
跳转到导航
跳转到搜索
创建页面,内容为“local p = {} local data = mw.loadData('Module:历史上的今天/数据') function p.show_range() local all_events = {} local output = {} local current_year = tonumber(os.date("%Y")) local current_time = os.time() for i = -10, 10 do local offset_time = current_time + (i * 24 * 60 * 60) local month = tonumber(os.date("%m", offset_time)) local day = tonumber(os.date("%d", offset_time)) loca…” |
无编辑摘要 |
||
| 第42行: | 第42行: | ||
local refresh_date = mw.getContentLanguage():formatDate("Ynj") | local refresh_date = mw.getContentLanguage():formatDate("Ynj") | ||
table.insert(output, "") | table.insert(output, "") | ||
if #all_events > 0 then | if #all_events > 0 then | ||
2025年12月12日 (五) 13:00的版本
此模块的文档可以在模块:历史事件/doc创建
local p = {}
local data = mw.loadData('Module:历史上的今天/数据')
function p.show_range()
local all_events = {}
local output = {}
local current_year = tonumber(os.date("%Y"))
local current_time = os.time()
for i = -10, 10 do
local offset_time = current_time + (i * 24 * 60 * 60)
local month = tonumber(os.date("%m", offset_time))
local day = tonumber(os.date("%d", offset_time))
local key = month .. "-" .. day
local events = data[key]
if events then
for _, item in ipairs(events) do
table.insert(all_events, {
sort_key = month * 100 + day,
year = item.year,
month = month,
day = day,
event_desc = item.event
})
end
end
end
table.sort(all_events, function(a, b)
if a.sort_key ~= b.sort_key then
return a.sort_key < b.sort_key
else
return a.year < b.year
end
end)
local refresh_date = mw.getContentLanguage():formatDate("Ynj")
table.insert(output, "")
if #all_events > 0 then
for _, event in ipairs(all_events) do
local years_ago = current_year - event.year
-- 格式:2019年12月10日 (6 年前): xxxx
local line = string.format(
"* '''%d年%d月%d日''' (%d 年前): %s",
event.year,
event.month,
event.day,
years_ago,
event.event_desc
)
table.insert(output, line)
end
else
table.insert(output, "近二十一天内没有历史事件记录")
end
-- 添加脚注/链接
table.insert(output, "\n<div style=\"text-align: right; margin-top: 5px; font-size: 85%;\">")
table.insert(output, "[[年表|查看完整年表]]")
table.insert(output, "</div>")
return table.concat(output, "\n")
end
return p