Module:Sandbox/DannyS712/remind explained

-- This module powers .

local p =

-- Constantslocal lang = mw.language.getContentLanguagelocal getArgs = require('Module:Arguments').getArgs

local function formatMessage(secondsLeft, event, color, refreshLink) local timeLeft = lang:formatDuration(secondsLeft,) -- Find whether we are plural or not. local isOrAre if string.match(timeLeft, '^%d+')

'1' then isOrAre = 'is' else isOrAre = 'are' end -- Color and bold the numbers, because it makes them look important. local timeLeft = string.gsub(timeLeft, '(%d+)', '

%1') -- Make the refresh link and join it all together. return string.format('There %s %s until %s.%s', isOrAre, timeLeft, event, refreshLink)end

function p.main(frame) local args = getArgs(frame)

if not (args.year and args.month and args.day) then return 'Error: year, month, and day must be specified' end if not (args.reminder) then return 'Error: reminder must be specified' end

local eventTime = os.time local timeToStart = os.difftime(eventTime, os.time) -- (future time - current time)

if timeToStart > 0 then -- Reminder still pending return else -- Reminder due return args.reminder endend

return p