local data = mw.loadData('Module:Ancient Olympiads/data')local lang = mw.language.getContentLanguagelocal TableTools = require('Module:TableTools')
local p =
function p._main(inputYear) -- Convert the input to an integer if possible. Return "N/A" if the input could -- not be converted, or if the converted input is too big or too small. inputYear = tonumber(inputYear) if not inputYear or inputYear > tonumber(lang:formatDate('Y')) then return "N/A" end local dataLength = TableTools.length(data)
-- Find the year in the data page and display the output. for i = dataLength, 1, -1 do local t = data[i] if inputYear - 1
-- If input year is before 776 BC (-775), the year of the first Olympiad. return string.format('%d before 1st Olympiad', inputYear * -1 - 775 )end
function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) return p._main(args[1 ])end
return p