Módulo:Teste: diferenças entre revisões

Fonte: eViterbo
Saltar para a navegação Saltar para a pesquisa
Sem resumo de edição
Sem resumo de edição
Linha 12: Linha 12:


  if tonumber(d) and tonumber(m) and tonumber(y) > 0 then
  if tonumber(d) and tonumber(m) and tonumber(y) > 0 then
     data_str = d + '/'+ m + '/'+ y
     data_str = d .. '/' .. m .. '/' .. y
  end
  end
  if tonumber(m)  and tonumber(y) > 0 then
  if tonumber(m)  and tonumber(y) > 0 then
     data_str = m + '/'+ y
     data_str = m .. '/' .. y
  end
  end
  if tonumber(y) > 0 then
  if tonumber(y) > 0 then

Revisão das 16h02min de 12 de maio de 2020

A documentação para este módulo pode ser criada na página Módulo:Teste/doc

local p = {}

function p.foo(frame)
    return mw.logObject(mw.wikibase.getEntity("Q27"))
end

function p.qualifiers(frame)
   local data_str
   local entity = mw.wikibase.getEntity(frame.args[1])
   local snak = entity['claims']['P26'][1]['qualifiers']['P9'][1]['datavalue']['value']['time']
   _,_,y,m,d=string.find(snak, "(%d+)-(%d+)-(%d+)")

 if tonumber(d) and tonumber(m) and tonumber(y) > 0 then
    data_str = d .. '/' .. m .. '/' .. y
 end
 if tonumber(m)  and tonumber(y) > 0 then
    data_str = m .. '/' .. y
 end
 if tonumber(y) > 0 then
    data_str = y
 end

   return data_str

end

return p