Module:Sandbox list:修订间差异
来自存档计划,Project Archive by Lakejason0
添加的内容 删除的内容
Lakejason0(讨论 | 贡献) |
Lakejason0(讨论 | 贡献) |
||
(未显示同一用户的7个中间版本) | |||
第8行: | 第8行: | ||
|namespace={{NAMESPACE}} |
|namespace={{NAMESPACE}} |
||
|noresultsheader=没有子页面 |
|noresultsheader=没有子页面 |
||
|format=,¶* |
|format=,¶* --%PAGE%--DATE--,, |
||
|ordermethod=lastedit |
|ordermethod=lastedit |
||
|addeditdate=true |
|||
|userdateformat=U |
|||
}}]==] |
}}]==] |
||
local localtime = f:preprocess "{{#timel:U|{{LOCALTIMESTAMP}}}}" |
|||
local timezone = function() |
|||
local now = os.time() |
|||
return os.difftime(now, os.time(os.date("!*t", now))) |
|||
end |
|||
local subst = function(...) |
local subst = function(...) |
||
-- Unix timestamp |
-- Unix timestamp |
||
local |
local page, _ = ... |
||
local time = f:preprocess('{{#time: U | {{REVISIONTIMESTAMP:' .. page .. '}}}}') |
|||
if |
if not time:find 'error' then |
||
time = os.difftime( |
time = os.difftime(os.time() + timezone(), tonumber(time)) |
||
return |
return '[[' .. page .. ']]<br>最后编辑于' .. mw.getContentLanguage():formatDuration(time, { 'years', 'weeks', 'days', 'hours', 'minutes' }) .. '前' |
||
else |
else |
||
return |
return '[[' .. page .. ']]' |
||
end |
end |
||
end |
end |
||
local result = dpl:gsub('( |
local result = dpl:gsub('%-%-(.-)%-%-DATE%-%-', subst) |
||
return result |
return result |
2021年5月15日 (六) 07:41的最新版本
local p = {}
function p.main()
local f = mw.getCurrentFrame()
local dpl = f:preprocess [==[{{#dpl:
|titleregexp=沙盒¦Sandbox/
|namespace={{NAMESPACE}}
|noresultsheader=没有子页面
|format=,¶* --%PAGE%--DATE--,,
|ordermethod=lastedit
}}]==]
local timezone = function()
local now = os.time()
return os.difftime(now, os.time(os.date("!*t", now)))
end
local subst = function(...)
-- Unix timestamp
local page, _ = ...
local time = f:preprocess('{{#time: U | {{REVISIONTIMESTAMP:' .. page .. '}}}}')
if not time:find 'error' then
time = os.difftime(os.time() + timezone(), tonumber(time))
return '[[' .. page .. ']]<br>最后编辑于' .. mw.getContentLanguage():formatDuration(time, { 'years', 'weeks', 'days', 'hours', 'minutes' }) .. '前'
else
return '[[' .. page .. ']]'
end
end
local result = dpl:gsub('%-%-(.-)%-%-DATE%-%-', subst)
return result
end
return p