Module:Calendar: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
p.format = function(frame)
p.format = function(frame)
local system = def(frame.args.cal, def(frame.args[1], 'gregorian'))
local system = def(frame.args.cal, def(frame.args[1], 'gregorian'))
if mw.title.new('Calendar/' .. system, 'Module').exists() then
if mw.title.new('Calendar/' .. system, 'Module').exists then
local cal = require("Module:Calendar/"..system)
local cal = require("Module:Calendar/"..system)
cal.to_formatted(cal.from(frame.args), frame.args)
return cal.to_formatted(cal.from(frame.args), frame.args)
else
else
return '<p style="color: red"><code>Module:Calendar</code> error: no such calendar: <code>' .. system .. '</code></p>[[Category:Pages with script errors]]'
return '<p style="color: red"><code>Module:Calendar</code> error: no such calendar: <code>' .. system .. '</code></p>[[Category:Pages with script errors]]'
end
end
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
return p

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