Module:Weekly site information: Difference between revisions
Jump to navigation
Jump to search
Dat Hack3r (talk | contribs) m (Dat Hack3r moved page Module:Last Weekly Briefing Release number to Module:Weekly Briefing Release without leaving a redirect: This module name is more appropriate for planned functionality.) |
Dat Hack3r (talk | contribs) (Test successful, deploying new version.) |
||
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 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:06, 27 November 2024
This Lua module is a high priority for maintenance as it is original to the OWOT Wiki and used in articles. As such, this module may contain bugs and it should be a top priority of module maintainers to quickly fix any issues that arise with it. Discuss breaking changes on the talk page before implementing them. |
This module implements {{Weekly site information}}
.
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