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( startdate, enddate ) categories = "" if not startdate then return "" end if not enddate then enddate = lang:formatDate( "Y-m-d", "now" ) end curdate = tostring( startdate ) enddate = tostring( enddate )

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 ) quarter = math.ceil( tonumber( lang:formatDate( "m", date ) ) / 3 ) year = lang:formatDate( "Y", tostring( catdate ) ) return "\n" end

return p