Module:GeneralPortCargoLog: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary |
NewZimiaGov (talk | contribs) Undo revision 359886 by NewZimiaGov (talk) Tag: Undo |
||
| Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
local function getCurrentDate() | |||
function | |||
local startDate = os.time({year = 1999, month = 8, day = 6}) | local startDate = os.time({year = 1999, month = 8, day = 6}) | ||
local | local currentDate = os.time() - (6 * 60 * 60) -- adjust for local timezone (UTC−6) | ||
local daysPerYear = 183 | local daysPerYear = 183 | ||
local totalDaysElapsed = math.floor((currentDate - startDate) / 86400) | |||
local year = math.floor(totalDaysElapsed / daysPerYear) | |||
local totalDaysElapsed = math.floor((currentDate - startDate) / | local day = (totalDaysElapsed % daysPerYear) + 1 | ||
return year, day | |||
local | |||
local | |||
return | |||
end | end | ||
Revision as of 22:41, 23 April 2025
Documentation for this module may be created at Module:GeneralPortCargoLog/doc
-- Module:GeneralPortCargoLog
local p = {}
local function getCurrentDate()
local startDate = os.time({year = 1999, month = 8, day = 6})
local currentDate = os.time() - (6 * 60 * 60) -- adjust for local timezone (UTC−6)
local daysPerYear = 183
local totalDaysElapsed = math.floor((currentDate - startDate) / 86400)
local year = math.floor(totalDaysElapsed / daysPerYear)
local day = (totalDaysElapsed % daysPerYear) + 1
return year, day
end
local function randomChoice(t)
return t[math.random(#t)]
end
function p.generateCargoLog()
local year, day = getCurrentDate()
local dateStr = string.format("Day %d, Y.%d", day, year)
local containerCraneOps = math.random(300, 700)
local bulkOps = math.random(100, 300)
local liquidOps = math.random(80, 250)
local avgTurnaroundTime = math.random(12, 36) + math.random()
local log = "{| class=\"wikitable\" style=\"width:100%\"\n"
log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Cargo Handling Log (%s)\n", dateStr)
log = log .. "|-\n"
log = log .. string.format("| '''Container Crane Operations''' || %d moves\n", containerCraneOps)
log = log .. "|-\n"
log = log .. string.format("| '''Bulk Cargo Handled''' || %d tons\n", bulkOps)
log = log .. "|-\n"
log = log .. string.format("| '''Liquid Cargo Handled''' || %d tons\n", liquidOps)
log = log .. "|-\n"
log = log .. string.format("| '''Average Turnaround Time''' || %.2f hours\n", avgTurnaroundTime)
log = log .. "|}"
return log
end
function p.dailyCargoSummary()
local year, day = getCurrentDate()
local header = string.format("'''General Port of Lake Morovia: Cargo Log – Day %d, Year %d PSSC'''\n", day, year)
return header .. p.generateCargoLog()
end
return p