本站为民间玩家交流站,不对官方产生任何影响
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~
融合版WIKI反馈群:556757324
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~
融合版WIKI反馈群:556757324
本站为民间玩家交流站,不对官方产生任何影响
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~
融合版WIKI反馈群:556757324
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~
融合版WIKI反馈群:556757324
全站通知:
模块:LastEditDays
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:LastEditDays/doc创建
local p = {}
function p.main(frame)
-- 方法1: 直接通过页面对象获取时间戳
local title = mw.title.getCurrentTitle()
local lastEdit = title.revisionTimestamp
-- 方法2: 如果方法1失败,使用解析器函数
if not lastEdit or lastEdit == "" then
lastEdit = frame:preprocess('{{REVISIONTIMESTAMP}}')
end
-- 方法3: 如果前两种方法都失败,使用当前时间作为备胎
if not lastEdit or lastEdit == "" then
lastEdit = os.date("%Y%m%d%H%M%S")
end
-- 提取年月日 (格式: YYYYMMDDHHMMSS)
local year = tonumber(lastEdit:sub(1,4))
local month = tonumber(lastEdit:sub(5,6))
local day = tonumber(lastEdit:sub(7,8))
-- 转换为时间戳
local editDate = os.time{year=year, month=month, day=day}
local currentDate = os.time()
-- 计算天数差 (86400秒=1天)
local diffDays = math.floor((currentDate - editDate) / 86400)
-- 创建显示文本
local displayText
if diffDays == 0 then
displayText = "此页面<b>今天</b>编辑过"
elseif diffDays == 1 then
displayText = "此页面<b>昨天</b>编辑过"
else
displayText = string.format('距离此页面最后一次编辑已过去 <b>%d天</b>(%d年%d月%d日)请注意内容时效性',
diffDays, year, month, day)
end
return string.format('<div class="last-edit-info">%s</div>', displayText)
end
return p