ci: fix
This commit is contained in:
parent
7ebfcc63c3
commit
9c5d57bece
7 changed files with 80 additions and 53 deletions
|
|
@ -32,11 +32,31 @@ end
|
|||
---@return string[]
|
||||
local function date_completions()
|
||||
return {
|
||||
'today', 'tomorrow', 'yesterday',
|
||||
'+1d', '+2d', '+3d', '+1w', '+2w', '+1m',
|
||||
'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun',
|
||||
'eod', 'eow', 'eom', 'eoq', 'eoy',
|
||||
'sow', 'som', 'soq', 'soy',
|
||||
'today',
|
||||
'tomorrow',
|
||||
'yesterday',
|
||||
'+1d',
|
||||
'+2d',
|
||||
'+3d',
|
||||
'+1w',
|
||||
'+2w',
|
||||
'+1m',
|
||||
'mon',
|
||||
'tue',
|
||||
'wed',
|
||||
'thu',
|
||||
'fri',
|
||||
'sat',
|
||||
'sun',
|
||||
'eod',
|
||||
'eow',
|
||||
'eom',
|
||||
'eoq',
|
||||
'eoy',
|
||||
'sow',
|
||||
'som',
|
||||
'soq',
|
||||
'soy',
|
||||
'later',
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ function M.check()
|
|||
for _, task in ipairs(tasks) do
|
||||
if task.recur and not recur.validate(task.recur) then
|
||||
invalid_count = invalid_count + 1
|
||||
vim.health.warn(
|
||||
'Task ' .. task.id .. ' has invalid recurrence spec: ' .. task.recur
|
||||
)
|
||||
vim.health.warn('Task ' .. task.id .. ' has invalid recurrence spec: ' .. task.recur)
|
||||
end
|
||||
end
|
||||
if invalid_count == 0 then
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ function M.toggle_complete()
|
|||
if task.recur and task.due then
|
||||
local recur = require('pending.recur')
|
||||
local mode = task.recur_mode or 'scheduled'
|
||||
local base = mode == 'completion' and os.date('%Y-%m-%d') --[[@as string]] or task.due
|
||||
local base = mode == 'completion' and os.date('%Y-%m-%d') --[[@as string]]
|
||||
or task.due
|
||||
local next_date = recur.next_due(base, task.recur, mode)
|
||||
store.add({
|
||||
description = task.description,
|
||||
|
|
|
|||
|
|
@ -45,9 +45,18 @@ local weekday_map = {
|
|||
}
|
||||
|
||||
local month_map = {
|
||||
jan = 1, feb = 2, mar = 3, apr = 4,
|
||||
may = 5, jun = 6, jul = 7, aug = 8,
|
||||
sep = 9, oct = 10, nov = 11, dec = 12,
|
||||
jan = 1,
|
||||
feb = 2,
|
||||
mar = 3,
|
||||
apr = 4,
|
||||
may = 5,
|
||||
jun = 6,
|
||||
jul = 7,
|
||||
aug = 8,
|
||||
sep = 9,
|
||||
oct = 10,
|
||||
nov = 11,
|
||||
dec = 12,
|
||||
}
|
||||
|
||||
---@param today osdate
|
||||
|
|
@ -97,49 +106,31 @@ function M.resolve_date(text)
|
|||
end
|
||||
|
||||
if lower == 'som' then
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = today.month, day = 1 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month, day = 1 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'eom' then
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = today.month + 1, day = 0 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month + 1, day = 0 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'soq' then
|
||||
local q = math.ceil(today.month / 3)
|
||||
local first_month = (q - 1) * 3 + 1
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = first_month, day = 1 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = first_month, day = 1 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'eoq' then
|
||||
local q = math.ceil(today.month / 3)
|
||||
local last_month = q * 3
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = last_month + 1, day = 0 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = last_month + 1, day = 0 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'soy' then
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = 1, day = 1 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = 1, day = 1 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'eoy' then
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = today.year, month = 12, day = 31 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = 12, day = 31 })) --[[@as string]]
|
||||
end
|
||||
|
||||
if lower == 'later' or lower == 'someday' then
|
||||
|
|
@ -153,7 +144,9 @@ function M.resolve_date(text)
|
|||
os.time({
|
||||
year = today.year,
|
||||
month = today.month,
|
||||
day = today.day + (tonumber(n) --[[@as integer]]),
|
||||
day = today.day + (
|
||||
tonumber(n) --[[@as integer]]
|
||||
),
|
||||
})
|
||||
) --[[@as string]]
|
||||
end
|
||||
|
|
@ -165,7 +158,9 @@ function M.resolve_date(text)
|
|||
os.time({
|
||||
year = today.year,
|
||||
month = today.month,
|
||||
day = today.day + (tonumber(n) --[[@as integer]]) * 7,
|
||||
day = today.day + (
|
||||
tonumber(n) --[[@as integer]]
|
||||
) * 7,
|
||||
})
|
||||
) --[[@as string]]
|
||||
end
|
||||
|
|
@ -176,7 +171,9 @@ function M.resolve_date(text)
|
|||
'%Y-%m-%d',
|
||||
os.time({
|
||||
year = today.year,
|
||||
month = today.month + (tonumber(n) --[[@as integer]]),
|
||||
month = today.month + (
|
||||
tonumber(n) --[[@as integer]]
|
||||
),
|
||||
day = today.day,
|
||||
})
|
||||
) --[[@as string]]
|
||||
|
|
@ -189,7 +186,9 @@ function M.resolve_date(text)
|
|||
os.time({
|
||||
year = today.year,
|
||||
month = today.month,
|
||||
day = today.day - (tonumber(n) --[[@as integer]]),
|
||||
day = today.day - (
|
||||
tonumber(n) --[[@as integer]]
|
||||
),
|
||||
})
|
||||
) --[[@as string]]
|
||||
end
|
||||
|
|
@ -201,7 +200,9 @@ function M.resolve_date(text)
|
|||
os.time({
|
||||
year = today.year,
|
||||
month = today.month,
|
||||
day = today.day - (tonumber(n) --[[@as integer]]) * 7,
|
||||
day = today.day - (
|
||||
tonumber(n) --[[@as integer]]
|
||||
) * 7,
|
||||
})
|
||||
) --[[@as string]]
|
||||
end
|
||||
|
|
@ -243,10 +244,7 @@ function M.resolve_date(text)
|
|||
if today.month >= target_month then
|
||||
y = y + 1
|
||||
end
|
||||
return os.date(
|
||||
'%Y-%m-%d',
|
||||
os.time({ year = y, month = target_month, day = 1 })
|
||||
) --[[@as string]]
|
||||
return os.date('%Y-%m-%d', os.time({ year = y, month = target_month, day = 1 })) --[[@as string]]
|
||||
end
|
||||
|
||||
local target_wday = weekday_map[lower]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,12 @@ local M = {}
|
|||
---@type table<string, pending.RecurSpec>
|
||||
local named = {
|
||||
daily = { freq = 'daily', interval = 1, from_completion = false },
|
||||
weekdays = { freq = 'weekly', interval = 1, byday = { 'MO', 'TU', 'WE', 'TH', 'FR' }, from_completion = false },
|
||||
weekdays = {
|
||||
freq = 'weekly',
|
||||
interval = 1,
|
||||
byday = { 'MO', 'TU', 'WE', 'TH', 'FR' },
|
||||
from_completion = false,
|
||||
},
|
||||
weekly = { freq = 'weekly', interval = 1, from_completion = false },
|
||||
biweekly = { freq = 'weekly', interval = 2, from_completion = false },
|
||||
monthly = { freq = 'monthly', interval = 1, from_completion = false },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue