Module:Calendar: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 13: Line 13:
end
end
p.convert = function(frame)
p.convert = function(frame)
local source = def(frame.args.source, def(frame.source[1]))
local source = def(frame.args.source, def(frame.args[1]))
local target = def(frame.args.target, def(frame.source[2]))
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
if mw.title.new('Calendar/' .. source, 'Module').exists and mw.title.new('Calendar/' .. target, 'Module').exists then
local src = require("Module:Calendar/"..source)
local src = require("Module:Calendar/"..source)

Latest revision as of 17:58, 22 May 2026

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