Module:Timeline: Difference between revisions

From aquila
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Tag: Reverted
Line 1: Line 1:
local Calendar = require("Module:Calendar")
local p = {}
local p = {}
 
local SEPARATOR = ";"
local dayLabels = {
local SPLIT_CHARACTERS = true
    "Early January", "January--February", "February--March", "March--April",
local LEGACY_MAX_EVENTS = 9
    "April--May", "May--June", "June", "June--July", "July--August",  
local EMPTY_ROW_TEXT = ""
     "August--September", "September--October", "October--November",  
     "November--December", "Late December"
local CARGO_TABLE = "NewsPosts"
local CARGO_FIELDS = "Page_Name,Title,Author,Publisher,RealDate,DayNum"
local CARGO_LIMIT = 1000
local DAY_LABELS = {}
for i, period in ipairs(Calendar.periods) do
     DAY_LABELS[i] = Calendar.pretty(period)
end
local DAYS_PER_YEAR = Calendar.daysPerYear
local SECTIONS = {
    Global    = "Global News",
    Domestic  = "Domestic News",
     Character = "Character News",
}
}
 
local TYPE_ALIASES = {
function p.render(frame)
    ["global"]        = "Global News",
     local year = tonumber(frame.args["Year"])
    ["global news"]    = "Global News",
     local category = frame.args["Category"]
    ["domestic"]      = "Domestic News",
     local categoryUpper = string.upper(category)
    ["domestic news"]  = "Domestic News",
      
    ["character"]      = "Character News",
     -- Fetch data from Cargo
    ["character news"] = "Character News",
     local cargoQuery = frame:callParserFunction('#cargo_query', {
}
         tables = 'NewsPosts',
        fields = 'Page_Name,Title,Type,RealDate,Author,Publisher,DayNum',
local COLUMNS = {
         where = 'YearNum=' .. tostring(year) .. ' AND Type="' .. categoryUpper .. ' News"',
    { "In-universe date",    "24%" },
        order_by = 'DayNum ASC, RealDate ASC'
    { "Post",                "34%" },
     })
    { "Character / nation",  "24%" },
   
    { "Real-world date",    "18%" },
    -- Parse Cargo results
}
local SEP_PATTERN = (SEPARATOR:gsub("%p", "%%%0"))
local function trim(s)
    return (tostring(s or ""):match("^%s*(.-)%s*$"))
end
local function errorText(message)
     return '<strong class="error">Timeline error: ' .. message .. "</strong>"
end
local function linkify(text)
    text = trim(text)
    if text == "" then return "" end
    if text:find("[[", 1, true) or text:find("^[%[<']") then
        return text
     end
    return "[[" .. text .. "]]"
end
local function linkifyCharacters(text)
    text = trim(text)
    if text == "" then return "" end
    if not SPLIT_CHARACTERS or text:find("[[", 1, true) or text:find("^[<']") then
        return linkify(text)
    end
     local parts = {}
    for part in (text .. ","):gmatch("(.-),") do
        part = trim(part)
        if part ~= "" then parts[#parts + 1] = linkify(part) end
    end
    return table.concat(parts, ", ")
end
local function normalizeTitle(name)
    name = trim((tostring(name or ""):gsub("_", " ")))
    return name:sub(1, 1):upper() .. name:sub(2)
end
local function linkTarget(wikitext)
     local target = tostring(wikitext or ""):match("^%[%[%s*:?([^%]|]+)")
     if target then
        return normalizeTitle(target)
     end
end
local function splitFields(line)
    line = line:gsub("(&#?%w+);", "%1\1")
    local fields = {}
    for field in (line .. SEPARATOR):gmatch("(.-)" .. SEP_PATTERN) do
         fields[#fields + 1] = trim((field:gsub("\1", ";")))
    end
    return fields
end
local function parseLine(line)
    line = trim(line)
    if line == "" then return nil end
    local f = splitFields(line)
    local post, char, date = f[1] or "", f[2] or "", f[3] or ""
    if post == "" and char == "" and date == "" then return nil end
    if post == "" then
         post = '<span class="error">(missing post title)</span>'
    else
        post = linkify(post)
    end
    if #f > 3 then
        post = post .. ' <span class="error">(too many “' .. SEPARATOR .. '” on this line)</span>'
    end
     return { post = post, char = linkifyCharacters(char), date = date }
end
local function collectManualEvents(getArg, day)
     local events = {}
     local events = {}
    for i = 1, 14 do events[i] = {} end
     local text = getArg("Day" .. day)
   
    if text and trim(text) ~= "" then
    -- Simple parser for Cargo's template output
        for line in (text .. "\n"):gmatch("(.-)\r?\n") do
     local rows = {}
             local ev = parseLine(line)
    for row in string.gmatch(cargoQuery, "<tr>(.-)</tr>") do
             if ev then events[#events + 1] = ev end
        local title, page, author, publisher, day = string.match(row, "<td>(.-)</td><td>(.-)</td><td>(.-)</td><td>(.-)</td><td>(.-)</td>")
        if day then
             local d = tonumber(day)
             if d and d >= 1 and d <= 14 then
                table.insert(events[d], {
                    Post = title,
                    Page = page,
                    Char = author ~= "" and author or publisher,
                    Date = "Auto" -- Handled by Cargo real date if needed
                })
            end
         end
         end
     end
     end
   
     for n = 1, LEGACY_MAX_EVENTS do
    -- Add manual events from Day1...Day14 parameters
         local prefix = "Day" .. day .. "_" .. n .. "_"
     for i = 1, 14 do
        local post = trim(getArg(prefix .. "Post"))
         local manualData = frame.args["Day" .. i]
        if post ~= "" then
        if manualData and manualData ~= "" then
            events[#events + 1] = {
            for line in string.gmatch(manualData, "[^\r\n]+") do
                post = linkify(post),
                local post, char = string.match(line, "^%s*(.-)%s*;%s*(.-)%s*$")
                char = linkifyCharacters(getArg(prefix .. "Char")),
                if post and post ~= "" then
                 date = trim(getArg(prefix .. "Date")),
                    table.insert(events[i], { Post = post, Char = char or "" })
             }
                 elseif post == nil and line ~= "" then
                    table.insert(events[i], { Post = line, Char = "" })
                end
             end
         end
         end
     end
     end
 
     return events
     -- Build the HTML table
end
    local html = {}
   
local function cargoEvents(typeName, year)
    -- Determine accent color based on category
     local byDay, names = {}, {}
     local headerBg = "#3a506b" -- Default slate
     for day = 1, DAYS_PER_YEAR do byDay[day] = {} end
     if categoryUpper == "CHARACTER" then headerBg = "#6e473b" end
   
     if not (mw.ext and mw.ext.cargo) then
     table.insert(html, '<div class="aquila-timeline-custom" style="border: 1px solid #d1d5db; border-radius: 12px; overflow: hidden; margin-bottom: 2em; box-shadow: 0 4px 12px rgba(0,0,0,0.05);">')
        return byDay, names, "the Cargo extension is not available to Lua"
      
     end
    -- Table Header
     table.insert(html, '<table style="width: 100%; border-collapse: collapse; background: #ffffff; margin: 0;">')
     local ok, rows = pcall(mw.ext.cargo.query, CARGO_TABLE, CARGO_FIELDS, {
    table.insert(html, '<tr>')
        where = 'Type="' .. typeName .. '" AND YearNum=' .. string.format("%d", year),
    table.insert(html, '<th colspan="4" style="background: ' .. headerBg .. '; color: #ffffff; font-family: \'Georgia\', serif; font-size: 1.1em; letter-spacing: 0.1em; text-align: center; padding: 12px; border-bottom: 3px solid #e0a96d;">' .. categoryUpper .. ' NEWS</th>')
        orderBy = "RealDate,_pageID",
    table.insert(html, '</tr>')
        limit = CARGO_LIMIT,
   
     })
    -- Column Headers
     if not ok then
    table.insert(html, '<tr>')
        return byDay, names, tostring(rows)
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 20%;">In-universe date</th>')
     end
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 35%;">Post</th>')
     table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 25%;">Character / nation</th>')
     for _, row in ipairs(rows) do
     table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 20%;">Real-world date</th>')
         local info = Calendar.info(row.RealDate)
    table.insert(html, '</tr>')
         local day = tonumber(row.DayNum) or (info and info.day)
 
        local page = trim(row.Page_Name)
     -- Loop through days
    local skipRows = 0
        if page ~= "" and day and day >= 1 and day <= DAYS_PER_YEAR then
     for i = 1, 14 do
            local title = trim(row.Title)
         if skipRows > 0 then
            if title == "" then
            skipRows = skipRows - 1
                title = page:match("[^/]+$") or page
         else
            end
            local eventCount = #events[i]
           
            local post
            if eventCount == 0 then
            if title == page then
                -- Empty Day Logic
                post = "[[" .. page .. "]]"
                local emptySpan = 1
            else
                for j = i + 1, 14 do
                 post = "[[" .. page .. "|" .. title .. "]]"
                    if #events[j] == 0 then
            end
                        emptySpan = emptySpan + 1
                    else
            local char
                        break
            if trim(row.Author) ~= "" then
                    end
                 char = linkify(row.Author)
                end
               
                local dateLabel = dayLabels[i]
                if emptySpan > 1 then
                    dateLabel = dayLabels[i] .. " to " .. dayLabels[i + emptySpan - 1]
                end
                 dateLabel = dateLabel .. ", Year " .. year
               
                table.insert(html, '<tr style="background: #fcfcfd;">')
                table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; color: #64748b; font-style: italic; font-size: 0.9em;">' .. dateLabel .. '</td>')
                table.insert(html, '<td colspan="3" style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; color: #94a3b8; font-style: italic;">No news</td>')
                 table.insert(html, '</tr>')
               
                skipRows = emptySpan - 1
             else
             else
                 char = linkifyCharacters(row.Publisher)
                 -- Event Logic
            end
                local rowspanAttr = ''
                if eventCount > 1 then
            names[normalizeTitle(page)] = true
                     rowspanAttr = ' rowspan="' .. eventCount .. '" '
            local list = byDay[day]
            list[#list + 1] = {
                post = post,
                char = char,
                date = info and info.iso or trim(row.RealDate),
            }
        end
    end
    return byDay, names
end
local function cell(content, attrs)
    return "<td" .. (attrs or "") .. ">" .. content .. "</td>"
end
local function rangeLabel(first, last, year)
    if first == last then
        return DAY_LABELS[first] .. ", Year " .. year
    end
    return DAY_LABELS[first] .. " to " .. DAY_LABELS[last] .. ", Year " .. year
end
local function renderSection(title, year, schedule)
    local out = {}
    out[#out + 1] = '<div style="overflow-x:auto;">'
    out[#out + 1] = '<table class="wikitable aquila-timeline" style="width:100%;">'
    out[#out + 1] = '<tr><th colspan="4" style="background-color:#f1f5f9; color:#0b132b; '
        .. 'text-align:center; font-weight:bold; padding:6px; text-transform:uppercase;">'
        .. title .. "</th></tr>"
    local head = {}
    for _, col in ipairs(COLUMNS) do
        head[#head + 1] = '<th style="width:' .. col[2] .. ';">' .. col[1] .. "</th>"
    end
    out[#out + 1] = "<tr>" .. table.concat(head) .. "</tr>"
    local day = 1
    while day <= DAYS_PER_YEAR do
        local events = schedule[day]
        local count = #events
        if count > 0 then
            local default = Calendar.realDate(year, day)
            local dates, span = {}, {}
            for i, ev in ipairs(events) do
                dates[i] = (ev.date ~= "") and ev.date or default
            end
            local i = 1
            while i <= count do
                local j = i
                while j < count and dates[j + 1] == dates[i] do j = j + 1 end
                span[i] = j - i + 1
                i = j + 1
            end
            for idx, ev in ipairs(events) do
                local row = {}
                if idx == 1 then
                     row[#row + 1] = cell(
                        DAY_LABELS[day] .. ", Year " .. year,
                        count > 1 and (' rowspan="' .. count .. '"') or ""
                    )
                 end
                 end
                 row[#row + 1] = cell(ev.post)
                  
                row[#row + 1] = cell(ev.char)
                for idx, event in ipairs(events[i]) do
                if span[idx] then
                    table.insert(html, '<tr style="background: #ffffff; transition: background 0.2s;">')
                     row[#row + 1] = cell(
                   
                         dates[idx],
                    -- Date Column (Only on first row of the day)
                        span[idx] > 1 and (' rowspan="' .. span[idx] .. '"') or ""
                    if idx == 1 then
                     )
                        table.insert(html, '<td' .. rowspanAttr .. 'style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; font-weight: bold; color: #1e293b; vertical-align: top;">' .. dayLabels[i] .. ', Year ' .. year .. '</td>')
                    end
                   
                    -- Post Column
                    local postText = event.Post
                    if event.Page and event.Page ~= "" then
                        postText = '[[' .. event.Page .. '|' .. event.Post .. ']]'
                    elseif not string.find(postText, "%[%[") and not string.find(postText, "<span>") then
                        postText = '[[' .. postText .. ']]'
                    end
                    table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; vertical-align: top;">' .. postText .. '</td>')
                   
                    -- Character Column
                    local charText = event.Char or ""
                    if charText ~= "" and not string.find(charText, "%[%[") and not string.find(charText, "<span>") then
                        charText = '[[' .. charText .. ']]'
                    end
                     table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; vertical-align: top;">' .. charText .. '</td>')
                   
                    -- Date Column
                    local realDate = event.Date or ""
                    if realDate == "Auto" then
                        local daysOffset = ((year - 1) * 14) + (i - 1)
                        local timestamp = os.time({year=2026, month=07, day=28, hour=12}) + (daysOffset * 86400)
                         realDate = os.date("%Y-%m-%d", timestamp)
                    end
                    table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; color: #64748b; font-size: 0.9em; white-space: nowrap;">' .. realDate .. '</td>')
                      
                    table.insert(html, '</tr>')
                 end
                 end
                out[#out + 1] = "<tr>" .. table.concat(row) .. "</tr>"
            end
            day = day + 1
        else
            local first = day
            while day <= DAYS_PER_YEAR and #schedule[day] == 0 do
                day = day + 1
            end
            local last = day - 1
            local startDate, endDate = Calendar.realDate(year, first), Calendar.realDate(year, last)
            local dateText = (first == last) and startDate or (startDate .. " to " .. endDate)
            out[#out + 1] = "<tr>"
                .. cell(rangeLabel(first, last, year))
                .. cell(EMPTY_ROW_TEXT, ' colspan="2"')
                .. cell(dateText)
                .. "</tr>"
        end
    end
    out[#out + 1] = "</table>"
    out[#out + 1] = "</div>"
    return table.concat(out, "\n")
end
function p.newsType(frame)
    local key = trim(frame.args[1]):lower()
    return TYPE_ALIASES[key] or SECTIONS.Character
end
function p.render(frame)
    local own = frame.args
    local parent = frame:getParent()
    local inherited = parent and parent.args or {}
    local function getArg(name)
        local v = inherited[name]
        if v == nil or trim(v) == "" then v = own[name] end
        return v
    end
    local key = trim(getArg("Category"))
    local title = SECTIONS[key]
    if not title then
        return errorText('unknown Category "' .. key .. '" (use Global, Domestic or Character).')
    end
    local year = tonumber(trim(getArg("Year")))
    if not year or year < 1 or year ~= math.floor(year) then
        return errorText("set <code>Year</code> to a whole number, 1 or higher.")
    end
    local auto, names, cargoError = {}, {}, nil
    if trim(getArg("Auto")):lower() ~= "no" then
        auto, names, cargoError = cargoEvents(title, year)
    end
    local schedule = {}
    for day = 1, DAYS_PER_YEAR do
        local events = {}
        for _, ev in ipairs(collectManualEvents(getArg, day)) do
            local target = linkTarget(ev.post)
            if not (target and names[target]) then
                events[#events + 1] = ev
             end
             end
         end
         end
        for _, ev in ipairs(auto[day] or {}) do
            events[#events + 1] = ev
        end
        schedule[day] = events
    end
    local html = renderSection(title, year, schedule)
    if cargoError then
        html = html .. '\n<div class="error">Could not read the Cargo table “' .. CARGO_TABLE
            .. "”: " .. cargoError .. "</div>"
     end
     end
     return html
 
    table.insert(html, '</table>')
    table.insert(html, '</div>')
   
     return table.concat(html, "\n")
end
end
 
return p
return p

Revision as of 10:40, 24 October 2026

Documentation for this module may be created at Module:Timeline/doc

local p = {}

local dayLabels = {
    "Early January", "January--February", "February--March", "March--April", 
    "April--May", "May--June", "June", "June--July", "July--August", 
    "August--September", "September--October", "October--November", 
    "November--December", "Late December"
}

function p.render(frame)
    local year = tonumber(frame.args["Year"])
    local category = frame.args["Category"]
    local categoryUpper = string.upper(category)
    
    -- Fetch data from Cargo
    local cargoQuery = frame:callParserFunction('#cargo_query', {
        tables = 'NewsPosts',
        fields = 'Page_Name,Title,Type,RealDate,Author,Publisher,DayNum',
        where = 'YearNum=' .. tostring(year) .. ' AND Type="' .. categoryUpper .. ' News"',
        order_by = 'DayNum ASC, RealDate ASC'
    })
    
    -- Parse Cargo results
    local events = {}
    for i = 1, 14 do events[i] = {} end
    
    -- Simple parser for Cargo's template output
    local rows = {}
    for row in string.gmatch(cargoQuery, "<tr>(.-)</tr>") do
        local title, page, author, publisher, day = string.match(row, "<td>(.-)</td><td>(.-)</td><td>(.-)</td><td>(.-)</td><td>(.-)</td>")
        if day then
            local d = tonumber(day)
            if d and d >= 1 and d <= 14 then
                table.insert(events[d], {
                    Post = title,
                    Page = page,
                    Char = author ~= "" and author or publisher,
                    Date = "Auto" -- Handled by Cargo real date if needed
                })
            end
        end
    end
    
    -- Add manual events from Day1...Day14 parameters
    for i = 1, 14 do
        local manualData = frame.args["Day" .. i]
        if manualData and manualData ~= "" then
            for line in string.gmatch(manualData, "[^\r\n]+") do
                local post, char = string.match(line, "^%s*(.-)%s*;%s*(.-)%s*$")
                if post and post ~= "" then
                    table.insert(events[i], { Post = post, Char = char or "" })
                elseif post == nil and line ~= "" then
                    table.insert(events[i], { Post = line, Char = "" })
                end
            end
        end
    end

    -- Build the HTML table
    local html = {}
    
    -- Determine accent color based on category
    local headerBg = "#3a506b" -- Default slate
    if categoryUpper == "CHARACTER" then headerBg = "#6e473b" end
    
    table.insert(html, '<div class="aquila-timeline-custom" style="border: 1px solid #d1d5db; border-radius: 12px; overflow: hidden; margin-bottom: 2em; box-shadow: 0 4px 12px rgba(0,0,0,0.05);">')
    
    -- Table Header
    table.insert(html, '<table style="width: 100%; border-collapse: collapse; background: #ffffff; margin: 0;">')
    table.insert(html, '<tr>')
    table.insert(html, '<th colspan="4" style="background: ' .. headerBg .. '; color: #ffffff; font-family: \'Georgia\', serif; font-size: 1.1em; letter-spacing: 0.1em; text-align: center; padding: 12px; border-bottom: 3px solid #e0a96d;">' .. categoryUpper .. ' NEWS</th>')
    table.insert(html, '</tr>')
    
    -- Column Headers
    table.insert(html, '<tr>')
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 20%;">In-universe date</th>')
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 35%;">Post</th>')
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 25%;">Character / nation</th>')
    table.insert(html, '<th style="background: #f8fafc; color: #1e293b; font-family: \'Georgia\', serif; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0; width: 20%;">Real-world date</th>')
    table.insert(html, '</tr>')

    -- Loop through days
    local skipRows = 0
    for i = 1, 14 do
        if skipRows > 0 then
            skipRows = skipRows - 1
        else
            local eventCount = #events[i]
            
            if eventCount == 0 then
                -- Empty Day Logic
                local emptySpan = 1
                for j = i + 1, 14 do
                    if #events[j] == 0 then
                        emptySpan = emptySpan + 1
                    else
                        break
                    end
                end
                
                local dateLabel = dayLabels[i]
                if emptySpan > 1 then
                    dateLabel = dayLabels[i] .. " to " .. dayLabels[i + emptySpan - 1]
                end
                dateLabel = dateLabel .. ", Year " .. year
                
                table.insert(html, '<tr style="background: #fcfcfd;">')
                table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; color: #64748b; font-style: italic; font-size: 0.9em;">' .. dateLabel .. '</td>')
                table.insert(html, '<td colspan="3" style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; color: #94a3b8; font-style: italic;">No news</td>')
                table.insert(html, '</tr>')
                
                skipRows = emptySpan - 1
            else
                -- Event Logic
                local rowspanAttr = ''
                if eventCount > 1 then
                    rowspanAttr = ' rowspan="' .. eventCount .. '" '
                end
                
                for idx, event in ipairs(events[i]) do
                    table.insert(html, '<tr style="background: #ffffff; transition: background 0.2s;">')
                    
                    -- Date Column (Only on first row of the day)
                    if idx == 1 then
                        table.insert(html, '<td' .. rowspanAttr .. 'style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; font-weight: bold; color: #1e293b; vertical-align: top;">' .. dayLabels[i] .. ', Year ' .. year .. '</td>')
                    end
                    
                    -- Post Column
                    local postText = event.Post
                    if event.Page and event.Page ~= "" then
                        postText = '[[' .. event.Page .. '|' .. event.Post .. ']]'
                    elseif not string.find(postText, "%[%[") and not string.find(postText, "<span>") then
                        postText = '[[' .. postText .. ']]'
                    end
                    table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; vertical-align: top;">' .. postText .. '</td>')
                    
                    -- Character Column
                    local charText = event.Char or ""
                    if charText ~= "" and not string.find(charText, "%[%[") and not string.find(charText, "<span>") then
                        charText = '[[' .. charText .. ']]'
                    end
                    table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #e2e8f0; vertical-align: top;">' .. charText .. '</td>')
                    
                    -- Date Column
                    local realDate = event.Date or ""
                    if realDate == "Auto" then
                        local daysOffset = ((year - 1) * 14) + (i - 1)
                        local timestamp = os.time({year=2026, month=07, day=28, hour=12}) + (daysOffset * 86400)
                        realDate = os.date("%Y-%m-%d", timestamp)
                    end
                    table.insert(html, '<td style="padding: 12px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: top; color: #64748b; font-size: 0.9em; white-space: nowrap;">' .. realDate .. '</td>')
                    
                    table.insert(html, '</tr>')
                end
            end
        end
    end

    table.insert(html, '</table>')
    table.insert(html, '</div>')
    
    return table.concat(html, "\n")
end

return p