Module:Calendar

From Nguhcraft Wiki
Revision as of 17:58, 22 May 2026 by Annwan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Submodules:


local p = {}

local def = require("Module:Utils").def

p.format = function(frame)
	local system = def(frame.args.cal, def(frame.args[1], 'gregorian'))
	if mw.title.new('Calendar/' .. system, 'Module').exists then
		local cal = require("Module:Calendar/"..system)
		return cal.to_formatted(cal.from(frame.args), frame.args)
	else
		return '<p style="color: red"><code>Module:Calendar</code> error: no such calendar: <code>' .. system .. '</code></p>[[Category:Pages with script errors]]'
	end
end
p.convert = function(frame)
	local source = def(frame.args.source, def(frame.args[1]))
	local target = def(frame.args.target, def(frame.args[2]))
	if mw.title.new('Calendar/' .. source, 'Module').exists and mw.title.new('Calendar/' .. target, 'Module').exists then
		local src = require("Module:Calendar/"..source)
		local out = require("Module:Calendar/"..target)
		return out.to_formatted(src.from(frame.args), frame.args)
	else
		return '<p style="color: red"><code>Module:Calendar</code> error: no such calendar: at least one of <code>' .. source .. '</code> or <code>'.. target ..'</code></p>[[Category:Pages with script errors]]'
	end
end


return p