Module:Year
Jump to navigation
Jump to search
function ProcessYear(RawYear)
-- Shared interal subroutine to process and read input
--[[ local n -- for section in string (1-5)
need to check if the first character of RawYear is numeric and, if so, set initial variables accordingly
For i = 1,string.len(RawYear) do -- iterate through the unprocessed input to split it into up to five sections
end
]]
return 'Foo' -- temporary command to test module
end
local year = {}
--[[ Module to handle the year parameter within the Author and Main namespaces.
This module will be passed a string, derived from the year parameter of a header template,
it will analyse the data and then output the correct visible and invisible (ie. categories) values.
]]
-- START TEMPORARY TEST FUNCTIONS
function year.MakeNumeric(str)
return tonumber(str)
end
function year.IsNumber(str)
local n = tonumber(str)
if n == nil then
return false
else
return true
end
end
function year.GetLength(str)
local len = mw.ustring.len(str) or ''
return len
end
-- END TEMPORARY TEST FUNCTIONS
function year.AuthorBirth(frame)
-- Entry point function for all author birth years (or equivalent strings)
local YearIn = frame.args[1] or ""
if YearIn == nil then -- if there is no input string..
return nil -- ..return nothing
elseif tonumber(YearIn) then -- if the input is a number..
return tonumber(YearIn) -- ..then return the input without processing
else
return ProcessYear(YearIn) .. ' births]]' -- in all other cases, process the input via the subroutine and append final part of category
end
end
function year.AuthorDeath(YearIn)
-- Entry point function for all author death years (or equivalent strings)
if tonumber(YearIn) ~= nil then -- if the input is a number..
return YearIn -- ..then return the input without processing
else
return 'Bar' -- temporary command to test module
end
end
function year.Work(YearIn)
-- Entry point function for all work publication years (or equivalent strings)
return 'Baz' -- temporary command to test module
end
return year