-- Replacement for local numberSpell = require('Module:NumberSpell')._mainlocal yesno = require('Module:Yesno')
local p =
function p._main(args) -- Initialize variables local lang = mw.language.getContentLanguage local auto_magnitude_num local min_magnitude_num local result local result_unit local magnitude = args.magnitude local min_magnitude = args.min_magnitude local purge = args.purge local spell_out = args.spellout local spell_out_max = args.spelloutmax -- Add a purge link if something (usually "yes") is entered into the purge parameter if purge then purge = '
([' .. mw.title.getCurrentTitle:fullUrl('action=purge') .. ' purge])' else purge = end-- Check that the entered timestamp is valid. If it isn't, then give an error message. local noError, inputTime = pcall(lang.formatDate, lang, 'U', args[1], true) if not noError then return 'Error: first parameter cannot be parsed as a date or time.' end
-- Store the difference between the current time and the inputted time, as well as its absolute value. local timeDiff = lang:formatDate('U', nil, true) - inputTime local absTimeDiff = math.abs(timeDiff)
-- Calculate the appropriate unit of time if it was not specified as an argument. local autoMagnitudeData = result = for i, t in ipairs(autoMagnitudeData) do if absTimeDiff / t.amn >= 1 then local result_num = math.floor(absTimeDiff / t.amn) if t.unit
then local result_num = math.floor(absTimeDiff/60) result = tostring(result_num) .. ' minutes' end return resultend
function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) return p._main(args)end
return p