Module:Sandbox/Dat Hack3r: Difference between revisions
Jump to navigation
Jump to search
Dat Hack3r (talk | contribs) No edit summary |
Dat Hack3r (talk | contribs) (Draft of new Module:Last Weekly Briefing Release number.) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function | local function release(prev) | ||
local first_date = os.time{year=2024, month=9, day=8} | |||
local | local curr_date = os.date("*t", os.time()) | ||
if prev == true then | |||
curr_date.day = curr_date.day - 7 | |||
end | |||
curr_date = os.time(curr_date) | |||
local diff = os.difftime(curr_date, first_date) / (24 * 60 * 60) | |||
local | local release_num = math.floor(diff / 7) | ||
local end_date = os.date("*t", curr_date - (diff % 7) * 24 * 60 * 60) | |||
local | end_date.day = end_date.day - (end_date.wday - 1) | ||
- | local start_date = os.time{year=end_date.year, month=end_date.month, day=end_date.day - 7} | ||
return " | |||
return release_num .. " " .. os.date("%b %d", start_date) .. " - " .. os.date("%b %d", os.time(end_date)) | |||
end | |||
function p.most_recent() | |||
return release(false) | |||
end | |||
function p.previous() | |||
return release(true) | |||
end | end | ||
return p | return p |
Revision as of 21:01, 27 November 2024
Documentation for this module may be created at Module:Sandbox/Dat Hack3r/doc
local p = {}
local function release(prev)
local first_date = os.time{year=2024, month=9, day=8}
local curr_date = os.date("*t", os.time())
if prev == true then
curr_date.day = curr_date.day - 7
end
curr_date = os.time(curr_date)
local diff = os.difftime(curr_date, first_date) / (24 * 60 * 60)
local release_num = math.floor(diff / 7)
local end_date = os.date("*t", curr_date - (diff % 7) * 24 * 60 * 60)
end_date.day = end_date.day - (end_date.wday - 1)
local start_date = os.time{year=end_date.year, month=end_date.month, day=end_date.day - 7}
return release_num .. " " .. os.date("%b %d", start_date) .. " - " .. os.date("%b %d", os.time(end_date))
end
function p.most_recent()
return release(false)
end
function p.previous()
return release(true)
end
return p