ical-expander icon indicating copy to clipboard operation
ical-expander copied to clipboard

DTEND should be non-inclusive

Open radarfox opened this issue 5 years ago • 3 comments

Hello,

I have discovered the bug in this library at the latest version 2.1. According to the RFC at 3.6.1:

The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event.

So for example, in this calendar:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:+//IDN ki-wi.cz//NONSGML Player Lighter//EN
BEGIN:VEVENT
UID:197857
DTSTAMP:20190920T025726Z
DTSTART:20200101T000000
DTEND:20201231T235900
SUMMARY:simple event
END:VEVENT
END:VCALENDAR

When you make a selection, that includes only the DTEND, it shouldn't contain any event or occurrences, but it does. DTEND + 1 works as expected and no event is returned.

const date = new Date('2020-12-31T23:59');
const match = expander.between(date, date);
return Boolean(match.events.length || match.occurrences.length);

This code will return true, but it should return false.

radarfox avatar Apr 15 '20 09:04 radarfox

I don't have time to look at this now, but if you provide a PR, I'm happy to consider merging

mifi avatar Apr 24 '20 14:04 mifi

I understand. Luckily, this precision is not a must-have for the app I'm working on, but for someone it might be quite a problem, so I decided to at least report it.

radarfox avatar Apr 25 '20 17:04 radarfox

IcalExpander.between() currently also has events in the result which end exactly at the beginning of the requested range. This is probably a related problem.

My current workaround is to shrink the requested range by 1 millisecond from each end.

ray007 avatar Feb 24 '23 09:02 ray007