Skip to content

Commit 5338159

Browse files
Do not try to parse invalid dates. Fixes #284
1 parent 936494e commit 5338159

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/orgmode/objects/date.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ end
184184
---@return Date
185185
local function from_string(datestr, opts)
186186
if not is_valid_date(datestr) then
187-
return now().clone(opts)
187+
return nil
188188
end
189189
local parts = vim.split(datestr, '%s+')
190190
local date = table.remove(parts, 1)
@@ -881,7 +881,10 @@ end
881881
local function parse_all_from_line(line, lnum)
882882
local dates = {}
883883
for open, datetime, close in line:gmatch(pattern) do
884-
table.insert(dates, from_match(line, lnum, open, datetime, close, dates[#dates]))
884+
local parsed_date = from_match(line, lnum, open, datetime, close, dates[#dates])
885+
if parsed_date then
886+
table.insert(dates, parsed_date)
887+
end
885888
end
886889
return dates
887890
end

0 commit comments

Comments
 (0)