Module:Time ago: Difference between revisions

Jump to navigation Jump to search
Use Module:Arguments, rename function to main.
(Cleanup and commenting.)
(Use Module:Arguments, rename function to main.)
Line 1:
-- Replacement for [[Template:Time ago]]
local HtmlBuilder = require('Module:HtmlBuilder')
local getArgs = require('Module:Arguments').getArgs
 
local p = {}
 
function p.timeAgomain( frame )
local args = getArgs( frame )
return p._main( args )
end
 
function p._main( args )
-- Initialize variables
local lang = mw.language.getContentLanguage()
Line 10 ⟶ 16:
local min_magnitude_num
local result
local magnitude = frame.args.magnitude
local min_magnitude = frame.args.min_magnitude
if frame.args.ago then ago = frame.args.ago else ago = 'ago' end
local purge = ''
 
-- Add a purge link if something (usually "yes") is entered into the purge parameter
if ( frame.args.purge ) then
local builder = HtmlBuilder.create()
builder
Line 29 ⟶ 35:
 
-- Check that the entered timestamp is valid. If it isn't, then give an error message.
local noError, inputTime = pcall( lang.formatDate, lang, 'U', frame.args[1] )
if not noError then
local builder = HtmlBuilder.create()
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu