跳转到内容

Module:Sandbox list:修订间差异

添加的内容 删除的内容
第15行: 第15行:
-- Unix timestamp
-- Unix timestamp
local page, _ = ...
local page, _ = ...
local time = f:preprocess('{{#timel: U | {{REVISIONTIMESTAMP:' .. page .. '}}}}')
local time = f:preprocess('{{#time: U | {{REVISIONTIMESTAMP:' .. page .. '}}}}')
if not time:find('error') then
if not time:find('error') then
time = os.difftime(os.time(), tonumber(time))
time = os.difftime(os.time(), tonumber(time))

2021年5月15日 (六) 07:35的版本

此模块没有文档页面。如果你知道如何使用模块,请创建它。
local p = {}
-- TODO: 修复因DPL返回的%DATE%随用户时区改变而导致时间显示错误的问题
function p.main()
	local f = mw.getCurrentFrame()

	local dpl = f:preprocess [==[{{#dpl:
		|titleregexp=沙盒¦Sandbox/
		|namespace={{NAMESPACE}}
		|noresultsheader=没有子页面
		|format=,¶* --%PAGE%--DATE--,,
		|ordermethod=lastedit
		}}]==]

	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(), 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
Cookie帮助我们提供我们的服务。通过使用我们的服务,您同意我们使用cookie。