DTEND DATE value is not reckoned exclusively
Closed this issue · 5 comments
A loaded event containing the property
DTEND;VALUE=DATE:20241128
is returned by GetOccurrences(new DateTime(2024, 11, 28))
. This is contrary to the spec, which says
The "DTEND" property for a "VEVENT" calendar component specifies the non-inclusive end of the event.
I understand this to mean that an event which ends by 0000 hours on a date is not an occurrence on that date.
Can you provide a reproducer and more details on the version you are using?
On the current main branch the following test succeeds:
[Test]
public void TestGetOccurrence_DtEndExcluded()
{
var ical = """
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART:20241201
DTEND:20241202
END:VEVENT
END:VCALENDAR
""";
var calendar = Calendar.Load(ical);
var occurrences = calendar.GetOccurrences(new CalDateTime("20241202")).ToList();
Assert.That(occurrences, Is.Empty);
}
Certainly. I am using Version 4.3.1 in .NET Framework 4.8.
Your test works for me but this string produces the bug when supplying 20241128 to GetOccurrences.
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Video Wall
BEGIN:VEVENT
UID:VW6
DTSTAMP:20240630T000000Z
DTSTART;VALUE=DATE:20241001
DTEND;VALUE=DATE:20241128
SUMMARY:New home speech.mp4
COMMENT:New location announcement; may need update before Thanksgiving
END:VEVENT
END:VCALENDAR
Oh yes, now I can reproduce it. The problem disappears when setting DTSTART to 20241101
. Probably the problem is related to the a DST change between DTSTART and DTEND. Assume, you are located in a timezone with positive offset and DST change in October like CET. Can you confirm? The lib incorrectly considers DTEND at 20241128 at 01:00 hours.
@axunonb FYI, likely related to faulty involvement of the local time zone.
Good sleuthing! Yes, I am in Pacific Time Zone with a summer offset of -7 hours and a change back to Standard Time on the second Sunday of November. Yet another reason to loathe the time-change kerfuffle.
@axunonb Btw., this is the full reproducing test case, just in case you can use it in #658.
[Test]
public void TestGetOccurrence_DtEndExcluded()
{
var ical = """
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Video Wall
BEGIN:VEVENT
UID:VW6
DTSTAMP:20240630T000000Z
DTSTART;VALUE=DATE:20241001
DTEND;VALUE=DATE:20241128
SUMMARY:New home speech.mp4
COMMENT:New location announcement; may need update before Thanksgiving
END:VEVENT
END:VCALENDAR
""";
var calendar = Calendar.Load(ical);
var occurrences = calendar.GetOccurrences(new CalDateTime("20241128")).ToList();
Assert.That(occurrences, Is.Empty);
}
Created the related ticket #660 which discusses the same topic for the case that DTSTART/DTEND are specified with a time zone reference.
[Edit] fixed c&p error