Module:DateInterval
From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 20:11, 1 May 2023 by Vish (talk | contribs) (Created page with "local p = {} local function calculateDate(date, interval) local currentDate = os.time() local startDate = os.time{year=date.year, month=date.month, day=date.day, hour=13} local secondsElapsed = currentDate - startDate local intervalsElapsed = math.floor(secondsElapsed / (86400 * interval)) local newDateTimestamp = startDate + (intervalsElapsed * 86400 * interval) local newDate = os.date("*t", newDateTimestamp) return string.format("%04d-%0...")
Documentation for this module may be created at Module:DateInterval/doc
local p = {}
local function calculateDate(date, interval)
local currentDate = os.time()
local startDate = os.time{year=date.year, month=date.month, day=date.day, hour=13}
local secondsElapsed = currentDate - startDate
local intervalsElapsed = math.floor(secondsElapsed / (86400 * interval))
local newDateTimestamp = startDate + (intervalsElapsed * 86400 * interval)
local newDate = os.date("*t", newDateTimestamp)
return string.format("%04d-%02d-%02d", newDate.year, newDate.month, newDate.day)
end
function p.dateInterval(frame)
local args = frame:getParent().args
local date = args.date or ""
local interval = tonumber(args.interval) or 7
local year, month, day = date:match("(%d%d%d%d)%-(%d%d)%-(%d%d)")
if not year or not month or not day then
return "Error: Invalid date format. Please use YYYY-MM-DD."
end
local dateTable = {year = tonumber(year), month = tonumber(month), day = tonumber(day)}
local resultDate = calculateDate(dateTable, interval)
local time = args.time or ""
local timezone = args.timezone or ""
return resultDate .. (time ~= "" and ", " .. time or "") .. (timezone ~= "" and " " .. timezone or "")
end
return p
- Manga ▾
- Media ▾
- Characters ▾
- World ▾
- Archives ▾
- Misc ▾
- Wiki ▾
Retrieved from "http://jojowiki.com/index.php?title=Module:DateInterval&oldid=840519"