fix(parse): cast os.date('*t') return to osdate (#3)
Problem: LuaLS types os.date('*t') as string|osdate, causing type
errors when accessing .year, .month, .day, .wday fields in
is_valid_date and resolve_date.
Solution: add --[[@as osdate]] casts on both os.date('*t') calls.
This commit is contained in:
parent
f21658f138
commit
68dbea7d52
1 changed files with 2 additions and 2 deletions
|
|
@ -21,7 +21,7 @@ local function is_valid_date(s)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local t = os.time({ year = y, month = m, day = d })
|
local t = os.time({ year = y, month = m, day = d })
|
||||||
local check = os.date('*t', t)
|
local check = os.date('*t', t) --[[@as osdate]]
|
||||||
return check.year == y and check.month == m and check.day == d
|
return check.year == y and check.month == m and check.day == d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ local weekday_map = {
|
||||||
---@return string|nil
|
---@return string|nil
|
||||||
function M.resolve_date(text)
|
function M.resolve_date(text)
|
||||||
local lower = text:lower()
|
local lower = text:lower()
|
||||||
local today = os.date('*t')
|
local today = os.date('*t') --[[@as osdate]]
|
||||||
|
|
||||||
if lower == 'today' then
|
if lower == 'today' then
|
||||||
return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month, day = today.day })) --[[@as string]]
|
return os.date('%Y-%m-%d', os.time({ year = today.year, month = today.month, day = today.day })) --[[@as string]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue