加帕里图书馆 - 兽娘动物园中文维基
动物朋友 けものフレンズ KemonoFriends百科
查看“︁模块:历史事件”︁的源代码
←
模块:历史事件
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local data = mw.loadData('Module:历史上的今天/数据') local function calculate_project_age(current_year) local project_start_year = 2014 local years_since_start = current_year - project_start_year return string.format( "距离企划开始已经%d年", years_since_start ) end function p.show_range() local all_events = {} local output = {} local current_year = tonumber(os.date("%Y")) local current_time = os.time() local refresh_date = mw.getContentLanguage():formatDate("Ynj") local project_age_string = calculate_project_age(current_year) table.insert(output, project_age_string) table.insert(output, "") -- 现在 output 数组是: [ "距离企划开始...", "", ... ] 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) if #all_events > 0 then -- 循环插入事件列表 for _, event in ipairs(all_events) do local years_ago = current_year - event.year 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
该页面使用的模板:
模块:历史事件/doc
(
查看源代码
)
返回
模块:历史事件
。
导航菜单
个人工具
创建账号
登录
命名空间
模块
讨论
English
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息