Module:InfoboxUtil

local lang = mw.getLanguage('en') local util_time = require('Module:TimeUtil') local Stat = require('Module:Stat')

local p = {} local h = {} function p.makeBday(y, m, d, death) -- expect death to be a string yyyy-mm-dd if not ((m and d) or death) then return {} end if not m then m = '1' end if not d then d = '1' end local m = tostring(util_time.monthNameToNumber[m]) if #m == 1 then m = '0' .. m	end if #d == 1 then d = '0' .. d	end local full = y and m and d	if not full then y = 2014 -- we won't print this, just a random year so that the formatting works end local str = ('%s-%s-%s'):format(y,m,d) local tbl = { full = full, age = full and util_time.age(str, death), display = h.pickAndGetDisplay(full, str, death), store = death or (full and str) or '' }	tbl.displayandage = tbl.display .. (full and (' (age %s)'):format(tbl.age) or '') return tbl end

function h.pickAndGetDisplay(full, str, death) if death then return h.getDisplay(death, true) end return h.getDisplay(str, full) end

function h.getDisplay(time, full) return full and lang:formatDate('F j, Y', time) or lang:formatDate('F j', time) end

function p.getFile(arg, default) local title = arg and mw.title.makeTitle('Media',arg or '') return title and title.exists and arg or default end

function p.statDisplays(tbl) local ret = {} for _, v in ipairs(tbl) do		ret[v] = Stat(v):flair end return ret end

return p