FANDOM


local p = {}
 
function p.table(frame)
    local days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
    local seconds_in_hour = 60 * 60
    local hours_in_day = 24
    local seconds_in_day = hours_in_day * seconds_in_hour
    local seconds_in_week = 7 * seconds_in_day
    local hours_in_week = 7 * hours_in_day
    local interval = 7
    local zero_day_index = 4 -- Thursday
    local max_waves_per_day = math.ceil(hours_in_day / interval)
 
    function get_time(day, n)
        local time = ((hours_in_day % interval) * (zero_day_index - day)) % interval + interval * (n - 1)
        if time >= hours_in_day then
            return false
        else
            return time
        end
    end
 
    function format_time(day, n)
        local time = get_time(day, n)
        if not time then
            return frame:preprocess("{{N/a}}")
        else
            local seconds_since_week_start = os.time() % seconds_in_week
            local hours_since_week_start = seconds_since_week_start / seconds_in_hour
            local hours = ((day - zero_day_index) * hours_in_day + time) % hours_in_week
            local style = ""
            local diff_hours = (hours - hours_since_week_start) % hours_in_week
            if diff_hours <= interval then
                mw.log("Next:", days[day], time)
                style = "background-color: yellow"
            end
            return string.format('style="%s" | %02d:00 UTC', style, time)
        end
    end
 
 
    local output = [[
        {| class="wikitable"
        |-
        ! ]]
 
    output = output .. table.concat(days, " !! ")
 
    for i=1,max_waves_per_day do
        output = output .. [[
 
            |-
            | ]]
        for day=1,#days do
            if day > 1 then
                output = output .. " || "
            end
            output = output .. format_time(day, i)
        end
    end
 
    output = output .. "\n|}"
 
    return output
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.