Jump to content

Module:Format time: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
args[1]
add as alias
Line 3: Line 3:
function p.main(frame)
function p.main(frame)
args = require('Module:Arguments').getArgs(frame)
args = require('Module:Arguments').getArgs(frame)
return p._main{fmt = args['fmt'], s = args[1]}
return p._main{fmt = args['fmt'], s = args['s'] or args[1]}
end
end



Revision as of 19:54, 28 June 2025

local p = {}

function p.main(frame)
	args = require('Module:Arguments').getArgs(frame)
	return p._main{fmt = args['fmt'], s = args['s'] or args[1]}
end

function p._main(args)
	-- args is a table with two values:
	-- fmt = the format to output the time, according to [[:mw:Help:Extension:ParserFunctions##time]] (default: j xg Y)
	-- s (or [1]) = the string to process; should be a date (default: empty string)
	return mw.getCurrentFrame():callParserFunction('#time', {args.fmt or 'j xg Y', require('Module:YMD to ISO')._main(args.s or args[1])})
end

return p