Module:Dates

From 2d4chan
Revision as of 01:05, 14 February 2025 by 2d4fag (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

local p = {}

function p.precision( frame )
    local input = frame.args[1]
    
    if input == nil or input == "" then
        return "empty"
    end
    if mw.ustring.find(input, "^%d%d%d%d%-%d%d%-%d%d$") then
        return "date"
    end
    if mw.ustring.find(input, "^%d%d%d%d%-%d%d$") then
        return "month"
    end
    if mw.ustring.find(input, "^%d%d%d%d$") then
        return "year"
    end
    return "unknown"
end

return p