Module:YenToUSD

From FamiWiki
Revision as of 16:57, 18 September 2023 by PanchamBro (talk | contribs) (updating conversion value)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

local function getArgs(frame)
    local args = {}
    for key, value in pairs(frame:getParent().args) do
        args[key] = value
    end
    for key, value in pairs(frame.args) do
        args[key] = value
    end
    return args
end

function p.main(frame)
    local args      = getArgs(frame)
    local yen       = args[1] or args.yen or ''
    return p.convert(yen)
end

function p.convert(yen)
	local conversion = 0.0068 -- Change this value every once in a while
	local usd = yen * conversion
	return math.floor(usd*100)/100
end

return p