--WIP, mfaizsyahmi
--doc for Dev:Date -
local p = {}
local date = require("Dev:Date")
local str_past = '<span class="label label-danger" title="The deadline of this item has passed. (%s)">–</span>'
local str_warn = '<span class="label label-warning" title="Less than %s days left until the deadline! (%s)">%s</span>'
local str_good = '<span class="label label-info" title="The item is still available. (%s)">%s</span>'
function p.main(frame)
    local str_deadline = frame.args[1] or '2020-12-31'
    local crithours = tonumber(frame.args[2]) or 72
    local date_now = date(true) -- in UTC
    local date_deadline = date(str_deadline)
    -- maybe check time here (they said it defaults to '12:00:00')
    local date_crittime = date_deadline:copy()
    date_crittime:addhours(0 - crithours)
    local s
    local days = math.ceil( (date_deadline:spanseconds() - date_now:spanseconds())/86400 )
    if date_now > date_deadline then
        s = string.format(str_past, date_deadline:fmt('%x %X'), days)
    elseif date_now > date_crittime then
        s = string.format(str_warn, days, date_deadline:fmt('%x %X'), days)
        s = string.format(str_good, date_deadline:fmt('%x %X'), days)
    return s
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.