Skip to content

Date parsing too lax? #71

@JulienPalard

Description

@JulienPalard

I had a typo in my org-file: <2024-11-12 14:00-17-00>

Yet orgparse parses it without complaining:

>>> orgparse.date.OrgDate.list_from_str("<2024-11-12 14:00-17-00>")
[OrgDate((2024, 11, 12, 14, 0, 0))]

With the typo fixed, the parsing get it right:

>>> orgparse.date.OrgDate.list_from_str("<2024-11-12 14:00-17:00>")
[OrgDate((2024, 11, 12, 14, 0, 0), (2024, 11, 12, 17, 0, 0))]

I would prefer an exception from invalid dates.

I may not fully know the org syntax for dates and maybe <2024-11-12 14:00-17-00> is kind-of-valid, like it could be a timezone offset of -00, haha, I hope no, I have not found it in the org manual yet.

Maybe a way to do it would be to restrict a bit the ignore regex like this:

-    if brtype == 'nobrace':
-        ignore = r'[\s\w]'
-    else:
-        ignore = '[^{bc}]'.format(bc=bc)
+    ignore = r'[\s\w]'

but looking at the full regex it feels like the ignore part is used too much :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions