From db837db2f3c7a958a0e750c7d723ab714b79c5f2 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 7 Mar 2026 01:54:09 -0500 Subject: [PATCH] fix: minor login --- lua/pending/init.lua | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lua/pending/init.lua b/lua/pending/init.lua index ee77c48..ccb5cf5 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -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