Module:Roman Year

Documentation for this module may be created at Module:Roman Year/doc

local p = {}

local numeral = require("Module:Roman Numeral")

local function _main(args)
	if args[1] == nil then return end
	local num = tonumber(args[1])
	if not num then return end
    if num > 0 then
        	avc = 753
    elseif num < 0 then
    	avc = 754
    end
    
    return numeral.main({num + avc}) .. ' AVC'

end

function p.main(frame)
    -- If called via #invoke, use the args passed into the invoking
    -- template, or the args passed to #invoke if any exist. Otherwise
    -- assume args are being passed directly in from the debug console
    -- or from another Lua module.
    local origArgs
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
        for k, v in pairs(frame.args) do
            origArgs = frame.args
            break
        end
    else
        origArgs = frame
    end
    -- Trim whitespace and remove blank arguments.
    local args = {}
    for k, v in pairs(origArgs) do
        if type( v ) == 'string' then
            v = mw.text.trim(v)
        end
        if v ~= '' then
            args[k] = v
        end
    end

    -- exit if not given anything
    if args == nil or args == {} then return end
    -- Given mathematical expression, simplify to a number
    if type(args[1]) == 'string' then
        args[1] = mw.ext.ParserFunctions.expr(args[1])
    end

    return _main(args)
end



return p