Module:Sandbox list

来自Minecraft基岩版开发Wiki
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道如何使用模块,请创建它。
local p = {}

function p.main()
	local f = mw.getCurrentFrame()

	local dpl = f:preprocess [==[{{#dpl:
		|titleregexp=沙盒¦Sandbox/
		|namespace={{NAMESPACE}}
		|noresultsheader=没有子页面
		|format=,¶* [[%PAGE%]]<br>最后编辑于:%DATE%:,,
		|ordermethod=lastedit
		|addeditdate=true
		|userdateformat=U
		}}]==]

	local subst = function(...)
		-- Unix timestamp
		local prefix, time = ...
		if type(time) == 'string' then
			time = os.difftime(os.time() + 3600 * 8, tonumber(time)) -- seconds between UTC and CST is 3600 * 8
			return prefix .. mw.getContentLanguage():formatDuration(time, { 'years', 'weeks', 'days', 'hours', 'minutes' }) .. '前'
		else
			return prefix .. time
		end
	end

	local result = dpl:gsub('(最后编辑于):(%d+):', subst)

	return result
end

return p