Module:Cat year: Difference between revisions

No edit summary
No edit summary
Line 12: Line 12:


-- Categorize each release
-- Categorize each release
if cat_type ~= 'song' and cat_type ~= '' then
if cat_type == '' then
for year in matches do
cat_type = 'song'
date_str = date_str .. '[[Category:' .. year .. ' ' .. string.lower(cat_type) .. 's]]'
end
end
for year in matches do
date_str = date_str .. '[[Category:' .. year .. ' ' .. string.lower(cat_type) .. 's]]'
end
end


-- Categorize the first release as just 'song' or 'album', etc.
-- Categorize the first release as just 'song' or 'album', etc.
local first_year = string.match( date_str, "%d%d%d%d" )
local first_year = string.match( date_str, "%d%d%d%d" )
if first_year then
if first_year and cat_type ~= 'song' then
date_str = date_str .. '[[Category:' .. first_year .. ' ' .. 'songs]]'
date_str = date_str .. '[[Category:' .. first_year .. ' ' .. 'songs]]'
end
end