Module:Autochangetemplate

--Automatically changes template after xx days -- use in template or directly -- Syntax = -- This module uses module:utility make sure it import it, or it won't work. local p = {} local u = require("Module:Utility") function p.main(frame) local oArgTableParent,oArgTableChild = u.getArgs(frame) oArgTable = oArgTableChild or oArgTableParent local iDays, sTemplate1, sTemplate2 = oArgTable["days"], oArgTable["template1"], oArgTable["template2"] local sNewTemplate = p.changeTemplate(iDays,sTemplate1,sTemplate2) return sNewTemplate end function p.changeTemplate(iDays,sTemplate1,sTemplate2) local sCat ="" if (iDays and sTemplate1 and sTemplate2) then local iFutureDate = u.addDays (os.date("%Y-%m-%d"),iDays) local iDaysLeft = u.datediff(os.date("%Y-%m-%d"),iFutureDate) local sTemplatePrefix = "")       else            sCat = preprocess(sTemplatePrefix .. sTemplate1 .. "}}")       end    end    return sCat end function preprocess(sText)    if (mw.getCurrentFrame) then        sText = mw.getCurrentFrame:preprocess(sText)    end   return sText end return p