ci: fix
This commit is contained in:
parent
7ebfcc63c3
commit
9c5d57bece
7 changed files with 80 additions and 53 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue