Module:Time ago: Difference between revisions

m
A little more cleanup.
(Use Module:Arguments, rename function to main.)
m (A little more cleanup.)
Line 16:
local min_magnitude_num
local result
local result_unit
local magnitude = args.magnitude
local min_magnitude = args.min_magnitude
Line 55 ⟶ 56:
min_magnitude_num = timeText[magnitude]
else
-- Calculate the appropriate unit of time if it was not specified as an argument.
if ( math.floor( absTimeDiff / 120 ) > 0 ) then auto_magnitude_num = 60 else auto_magnitude_num = 1 end
if ( math.floor( absTimeDiff / 7200 ) > 0 ) then auto_magnitude_num = 3600 end
Line 67 ⟶ 69:
local magnitude_num = math.max( min_magnitude_num, auto_magnitude_num )
local result_num = math.floor ( absTimeDiff / magnitude_num )
local result_unit
 
if ( timeDiff >= 0 ) then -- Past
Anonymous user