Module:KnightspireDate: Difference between revisions
From Knightspire Wiki
Jump to navigationJump to search
Content deleted Content added
Created page with "local p = {} function p.loreYear(frame) local input = frame.args[1] if not input or input == "" then return "" end local founded = mw.language.getContentLanguage():formatDate("U", input) local epoch = mw.language.getContentLanguage():formatDate("U", "2026-05-01") local diff = tonumber(founded) - tonumber(epoch) local weeks = math.floor(diff / 604800) return "Year " .. tostring(weeks + 1) end return p" |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
local epoch = os.time({ |
|||
year = 2026, |
|||
month = 5, |
|||
day = 1, |
|||
hour = 0 |
|||
}) |
|||
function p.loreYear(frame) |
function p.loreYear(frame) |
||
| Line 8: | Line 15: | ||
end |
end |
||
local year, month, day = input:match("(%d+)%-(%d+)%-(%d+)") |
|||
local founded = mw.language.getContentLanguage():formatDate("U", input) |
|||
local epoch = mw.language.getContentLanguage():formatDate("U", "2026-05-01") |
|||
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 = |
local diff = founded - epoch |
||
local weeks = math.floor(diff / 604800) |
local weeks = math.floor(diff / 604800) |
||
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