Module:Tempnotice

-- Displays a notice for XX days -- based on the last date the page was saved/edited -- use in template or directly -- Syntax = -- Syntax = local p = {} local u = require("Dev:Utility") function p.main(frame) local oArgTable = u.getArgs(frame) 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("--") 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 = "" 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 --