Module:KnightspireDate: Difference between revisions

From Knightspire Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
(No difference)

Latest revision as of 06:12, 9 May 2026

Documentation for this module may be created at Module:KnightspireDate/doc

local p = {}

local epoch = os.time({
    year = 2026,
    month = 5,
    day = 1,
    hour = 0
})

function p.loreYear(frame)
    local input = frame.args[1]

    if not input or input == "" then
        return ""
    end

    local year, month, day = input:match("(%d+)%-(%d+)%-(%d+)")

    if not year then
        return "Invalid date"
    end

    local founded = os.time({
        year = tonumber(year),
        month = tonumber(month),
        day = tonumber(day),
        hour = 0
    })

    local diff = founded - epoch

    local weeks = math.floor(diff / 604800)

    return "Year " .. tostring(weeks + 1)
end

return p