FANDOM


--
-- Implements {{Time ago}}
--
 
local p = {}
 
local function core( ago, time, auto_magnitude_num, min_magnitude_num )
 
end
 
-- essentially validates time works
function p._timeago( time, ago, magnitude, min_magnitude, purge, frame )
 
    -- validate time is a time
 
{{#iferror: {{#time:U| {{{1|}}} }}
 |'''Error: first parameter cannot be parsed as a date or time.'''
 |{{Time ago/core
  |ago = {{{ago|ago}}}
  |time = {{{1|}}}
  |auto_magnitude_num = {{#if:{{{magnitude|}}}
   |0<!-- Make sure the specified {{{magnitude}}} is used -->
   |{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 120      ) | 1 | 0 }}+
    {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200     ) | 1 | 0 }}+
    {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 172800   ) | 1 | 0 }}+
    {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 5356800  ) | 2 | 0 }}+
    {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 63115200 ) | 1 | 0 }}
   }}
  }}
  |min_magnitude_num = {{#switch:{{#if:{{{magnitude|}}}
    |{{{magnitude}}}
    |{{{min_magnitude}}}
   }}
   |years   = 6
   |months  = 5
   |weeks   = 4
   |days    = 3
   |hours   = 2
   |minutes = 1
   |seconds
   |#default= 0
  }}
 }}
}}
 
    local purge = ''
 
    if yesno( args['purge'] ) then
        purge = mw.html.create( 'span' )
            :addClass( 'plainlinks )
            :wikitext( '([' .. frame:preprocess( {{fullurl:{{FULLPAGENAME}}|action=purge}} .. ' purge])'
            :done()
        purge = ' ' .. tostring( purge )
    end
 
 
end
 
function p.timeago( frame )
 
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.