local p = {}
function p._core(frame)
local weekday = tonumber(os.date('%u'))
local time = tonumber(os.date('%H%M', os.time()))
local show = ''
local purge_at = ''
if 1 <= weekday and weekday <= 4 then
if time < 1130 then
show = '1'
purge_at = '11:30'
elseif time < 2330 then
purge_at = '23:30'
else
show = '1'
purge_at = '+1 day 11:30'
end
elseif weekday == 5 then
if time < 1130 then
show = '1'
purge_at = '11:30'
else
purge_at = 'sunday 23:30'
end
elseif weekday == 6 then
purge_at = 'sunday 23:30'
else -- 7
if time < 2330 then
purge_at = '23:30'
else
purge_at = 'next monday 11:30'
end
end
return {
['show'] = show,
['purge_at'] = purge_at,
}
end
function p.show(frame)
return p._core(frame)['show']
end
function p.purge_at(frame)
return p._core(frame)['purge_at']
end
return p