anufrievroman / calcure

Modern TUI calendar and task manager with minimal and customizable UI.
https://anufrievroman.gitbook.io/calcure
MIT License
1.51k stars 43 forks source link

Showing extra day on all-day ICS event #89

Closed kkoyung closed 9 months ago

kkoyung commented 9 months ago

Issue

Calcure displays all-day ICS event with one extra day.

Here is an example of ICS event.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VEVENT
SUMMARY:two days event
DTSTART;VALUE=DATE:20231203
DTEND;VALUE=DATE:20231205
DTSTAMP:20231202T163238Z
UID:LSFHOYXWW9PRMRM1UMD0FUFRFSPJYA34JSOG
SEQUENCE:0
CATEGORIES:
END:VEVENT
END:VCALENDAR

From Section 3.6.1 of RFC 5545 (the spec of iCalendar), the start date DTSTART is inclusive, and the end date DTEND is non-inclusive. So, this example is a two days event (Dec 3 and 4). However, calcure shows it as a three days event (Dec 3, 4 and 5). One more extra day.

screenshot_2023-12-02_19:09:25

Inspection

I think the problem comes from calculating the repetition in loaders.py. https://github.com/anufrievroman/calcure/blob/f363ccc68abbe1921ccf47e15941b93bed62defe/calcure/loaders.py#L430 Since the end data is non-inclusive, we don't need to add 1 to the difference in days.

anufrievroman commented 9 months ago

Yes, this is probably right, I'll take a closer look. There's a bit of an issue with ics from different sources...

anufrievroman commented 9 months ago

I think I fixed it in e3787ed3cdb8ce558f4bc1b5dcd157f79d808a1d Please try the main branch

kkoyung commented 9 months ago

The all day events are shown at correct dates now. It works perfectly.