fix: minor login
This commit is contained in:
parent
522daf3a21
commit
60fa5a1f1a
1 changed files with 9 additions and 18 deletions
|
|
@ -688,28 +688,20 @@ end
|
||||||
---@param days? integer
|
---@param days? integer
|
||||||
---@return nil
|
---@return nil
|
||||||
function M.archive(days)
|
function M.archive(days)
|
||||||
days = days or 30
|
if days == nil then
|
||||||
local cutoff = os.time() - (days * 86400)
|
days = 30
|
||||||
|
end
|
||||||
|
local cutoff = os.date('!%Y-%m-%dT%H:%M:%SZ', os.time() - (days * 86400)) --[[@as string]]
|
||||||
local s = get_store()
|
local s = get_store()
|
||||||
local tasks = s:tasks()
|
local tasks = s:tasks()
|
||||||
|
log.debug(('archive: days=%d cutoff=%s total_tasks=%d'):format(days, cutoff, #tasks))
|
||||||
local archived = 0
|
local archived = 0
|
||||||
local kept = {}
|
local kept = {}
|
||||||
for _, task in ipairs(tasks) do
|
for _, task in ipairs(tasks) do
|
||||||
if (task.status == 'done' or task.status == 'deleted') and task['end'] then
|
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 task['end'] < cutoff then
|
||||||
if y then
|
archived = archived + 1
|
||||||
local t = os.time({
|
goto skip
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(kept, task)
|
table.insert(kept, task)
|
||||||
|
|
@ -998,8 +990,7 @@ function M.command(args)
|
||||||
local action = rest:match('^(%S+)')
|
local action = rest:match('^(%S+)')
|
||||||
run_sync(cmd, action)
|
run_sync(cmd, action)
|
||||||
elseif cmd == 'archive' then
|
elseif cmd == 'archive' then
|
||||||
local d = rest ~= '' and tonumber(rest) or nil
|
M.archive(tonumber(rest))
|
||||||
M.archive(d)
|
|
||||||
elseif cmd == 'due' then
|
elseif cmd == 'due' then
|
||||||
M.due()
|
M.due()
|
||||||
elseif cmd == 'filter' then
|
elseif cmd == 'filter' then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue