Module:Wikimedia engineering project date categories

-- Module to output Category:WMF Projects subcategories -- as appropriate for a start and end date, to be used in --

local p = {} local lang = mw.language.getContentLanguage

function p.datesToCategories( frame ) local categories = "" local startdate, curdate, enddate if (not frame.args.startdate) or frame.args.startdate == "" then return "" else curdate = frame.args.startdate if string.len(curdate) < 4 then return "" end if string.len(curdate) == 4 then curdate = curdate .. "-01"   	end end if (not frame.args.enddate) or frame.args.enddate == "" then -- Ends now enddate = lang:formatDate( "Y-m-d" ) -- Current project categories = categories .. ""   else enddate = frame.args.enddate if string.len(enddate) == 4 then enddate = enddate .. "-12"   	end end

while lang:formatDate( "U", curdate ) < lang:formatDate( "U", enddate ) do       -- Hopefully not so many string as to break the garbage collector. categories = categories .. p.makeCategory( curdate ) curdate = lang:formatDate( "Y-m-d", curdate .. "+3 months" ) end categories = categories .. p.makeCategory( enddate ) return categories end

function p.makeCategory( catdate ) local quarter, year, trail quarter = math.ceil( tonumber( lang:formatDate( "m", catdate ) ) / 3 ) year = lang:formatDate( "Y", catdate ) trail = mw.getCurrentFrame:callParserFunction( '#translation', '' ) return "" end

return p