Modul:Common: Unterschied zwischen den Versionen

keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 16: Zeile 16:
local args = frame.args
local args = frame.args
     local title = mw.title.getCurrentTitle().text
     local title = mw.title.getCurrentTitle().text
     local tag, monat = title:match("^(%d%d?)%.%s*(%a+)$")
     local tag, monat = istJahrestag(title)
      
      
    -- Prüfe auf ein-/zweistellige Zahl durch Punkt gefolgt, opt. Leerzeichen
     if tag and monat then
     if tag and monat then
         return frame.args[1] or "true"
         return frame.args[1] or "true"
Zeile 24: Zeile 23:
         return frame.args[2] or ""
         return frame.args[2] or ""
     end
     end
end
function istJahrestag(s)
-- Prüfe auf ein-/zweistellige Zahl durch Punkt gefolgt, opt. Leerzeichen
return s:match("^(%d%d?)%.%s*(%a+)$")
end
end


Zeile 30: Zeile 34:
     local title = mw.title.getCurrentTitle().text
     local title = mw.title.getCurrentTitle().text


    -- Prüfe auf Formate wie: 2024, -44, 44 v. Chr., 800 n. Chr.
     if istJahreszahl(title) then
     if title:match("^%-?%d+$") or title:match("^%d+%s+[vn]%.%s+Chr%.$") then
         return args[1] or "true"
         return args[1] or "true"
     else
     else
         return args[2] or ""
         return args[2] or ""
     end
     end
end
function istJahreszahl(s)
-- Prüfe auf Formate wie: 2024, -44, 44 v. Chr., 800 n. Chr.
return s:match("^%-?%d+$") or title:match("^%d+%s+[vn]%.%s+Chr%.$")
end
end