recurrent icon indicating copy to clipboard operation
recurrent copied to clipboard

Wrongly detected date (on misuse of 'at')

Open Mayerch1 opened this issue 2 years ago • 0 comments

The string every other year at 26th march is wrongly detected as containing BYHOUR=26

It is caused by the regex RE_AT_TIME which is expanding to

at\s(?P<hour>\d{1,2}):?(?P<minute>\d{2})?\s?(?P<mod>am?|pm?)?(o\'?clock)?

I'd propose to use the following look-ahead, to ensure the number is not followed by st, nd or th. (?=[^(st|nd|th|0-9)])

So the complete RE_TIME Regex would look like follows

r'(?P<hour>\d{1,2})(?=[^(st|nd|th|0-9)]):?(?P<minute>\d{2})?\s?(?P<mod>am?|pm?)?(o\'?clock)?'

All given unit tests pass the regex modification.

Before I create a pull request on it, is this modified behaviour even desired? The English language doesn't use at to specify days, but it's nevertheless (wrongly) used by foreign speakers.

The big issue I see is, that similiar strings like every other year at 2nd july will not cause errors, but will result in an rrule, which repeats on 2nd july at 2am.

Mayerch1 avatar Feb 13 '22 19:02 Mayerch1