Modul:Tempnotice
Zur Navigation springen
Zur Suche springen
Die Dokumentation für dieses Modul kann unter Modul:Tempnotice/Doku erstellt werden
--<pre>Displays a notice for XX days -- based on the last date the page was saved/edited -- use in template or directly -- Syntax = {{#invoke:Tempnotice|main|days=2|notice="This message will self-destruct in ..."|template=true}} -- Syntax = {{#invoke:Tempnotice|main|days=2|notice=selfdestruct|template=true}} local p = {} local u = require("Module:Utility") function p.main(frame) local oArgTable = frame.args if (oArgTable) then local iDays = oArgTable["days"] local endDate = oArgTable["date"] local sArg1 = oArgTable[1] or oArgTable["notice"] local bTemplate = oArgTable["template"] return p.shownotice(iDays,sArg1,endDate,bTemplate) end end function p.shownotice(iDays,sArg1,endDate,bTemplate) local sCat ="" if (iDays or endDate) and sArg1 then local revDate =preprocess("{{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}") local dFutureDate = u.addDays (revDate,iDays) local todayDate = os.date("%Y-%m-%d") local iDaysLeft = u.datediff(dFutureDate,todayDate) local isValidDate = u.checkdate(endDate) local sPrefix,sSuffix ="","" if isValidDate then iDaysLeft = u.datediff(endDate,os.date("%Y-%m-%d")) end if bTemplate then sPrefix = "{{" sSuffix = "}}" end if iDaysLeft and iDaysLeft>0 then sCat = sPrefix .. sArg1 .. sSuffix end end return sCat end function preprocess(sText) if mw.getCurrentFrame() then sText = mw.getCurrentFrame():preprocess(sText) end return sText end return p --[[Category:Lua modules]]