Module:Monthly Birthdays
Documentation for this module may be created at Module:Monthly Birthdays/doc
local p = {}
local cargo = mw.ext.cargo
function p.birthdays(frame)
local month = mw.text.decode(frame.args[1])
if not month then return end
local escaped = string.gsub(month, "'", "\\'")
local query = {
where = "Characters.type = 'horsegirl' AND Characters.birthday IS NOT null AND SUBSTRING(Characters.birthday, 6, 2) = '" .. escaped .. "'",
orderBy = "SUBSTRING(Characters.birthday, 6, 5) ASC"
}
local fields = { 'name_en', 'birthday', 'color_main', 'color_sub' }
local events = cargo.query('Characters',
table.concat(fields, ','), query)
local text = ''
for _, ev in ipairs(events) do
local birthday = ev.birthday
if birthday then
local month = string.sub(birthday, 6, 7)
local day = string.sub(birthday, 9, 10)
text = text .. frame:expandTemplate {
title = 'Birthday Icon',
args = {
name = ev.name_en,
month = month,
day = day,
color_main = ev.color_main,
color_sub = ev.color_sub
}
} .. '\n'
end
end
return text
end
return p