ماڈیول:Potd-date

آزاد دائرۃ المعارف، ویکیپیڈیا سے
Documentation icon دستاویز [تخلیق]
local p = {}

function p.get( frame )
    local isodate, year, month, day, title, prefix
    prefix = frame.args[1]
    isodate = frame.args[2]
    year, month, day = isodate:match("(%d+)\-(%d+)\-(%d+)")
    title = mw.title.new( prefix .. year .. "-" .. month .. "-" .. day )
    while not title.exists do
        year = year - 1
        title = mw.title.new( prefix .. year .. "-" .. month .. "-" .. day )
    end
    return title
end

return p