fix: minor login

This commit is contained in:
Barrett Ruth 2026-03-07 01:54:09 -05:00
parent 522daf3a21
commit 60fa5a1f1a

View file

@ -688,28 +688,20 @@ end
---@param days? integer
---@return nil
function M.archive(days)
days = days or 30
local cutoff = os.time() - (days * 86400)
if days == nil then
days = 30
end
local cutoff = os.date('!%Y-%m-%dT%H:%M:%SZ', os.time() - (days * 86400)) --[[@as string]]
local s = get_store()
local tasks = s:tasks()
log.debug(('archive: days=%d cutoff=%s total_tasks=%d'):format(days, cutoff, #tasks))
local archived = 0
local kept = {}
for _, task in ipairs(tasks) do
if (task.status == 'done' or task.status == 'deleted') and task['end'] then
local y, mo, d, h, mi, sec = task['end']:match('^(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)Z$')
if y then
local t = os.time({
year = tonumber(y) --[[@as integer]],
month = tonumber(mo) --[[@as integer]],
day = tonumber(d) --[[@as integer]],
hour = tonumber(h) --[[@as integer]],
min = tonumber(mi) --[[@as integer]],
sec = tonumber(sec) --[[@as integer]],
})
if t < cutoff then
archived = archived + 1
goto skip
end
if task['end'] < cutoff then
archived = archived + 1
goto skip
end
end
table.insert(kept, task)
@ -998,8 +990,7 @@ function M.command(args)
local action = rest:match('^(%S+)')
run_sync(cmd, action)
elseif cmd == 'archive' then
local d = rest ~= '' and tonumber(rest) or nil
M.archive(d)
M.archive(tonumber(rest))
elseif cmd == 'due' then
M.due()
elseif cmd == 'filter' then