khal icon indicating copy to clipboard operation
khal copied to clipboard

Importing a ICS file with an event which rescheduled within one day creates two events at the day

Open ANtlord opened this issue 3 months ago • 3 comments

Describe the bug I have an event which happens every day at 11:40. I've run into a problem with rescheduling the event within a day. In the following example, I moved the event from 11:40 to 14:40. However, khal shows the old and the new event at the day.

If applicable: Stack Trace It does not crash.

To Reproduce

  1. Save the following output to /tmp/khaltest/private/8af16f25-ee94-40cb-985d-591e2f3c8f87.ics
BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.5.3-ose ical4j/3.2.19
BEGIN:VTIMEZONE
TZID:Europe/Dublin
BEGIN:STANDARD
DTSTART:19961027T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
TZNAME:GMT
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19810329T010000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
TZNAME:IST
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:8af16f25-ee94-40cb-985d-591e2f3c8f87
DTSTART;TZID=Europe/Dublin:20250909T114000
DTEND;TZID=Europe/Dublin:20250909T120000
DTSTAMP:20250916T144605Z
EXDATE;TZID=Europe/Dublin:20250913T114000,20250909T114000
RRULE:FREQ=DAILY;INTERVAL=1
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Desayuno
END:VEVENT
BEGIN:VEVENT
UID:8af16f25-ee94-40cb-985d-591e2f3c8f87
RECURRENCE-ID;TZID=Europe/Dublin:20250916T144000
DTSTART;TZID=Europe/Dublin:20250916T144000
DTEND;TZID=Europe/Dublin:20250916T150000
DESCRIPTION:
DTSTAMP:20250916T144605Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Desayuno
END:VEVENT
END:VCALENDAR
  1. Create configuration for khal with the following content at /tmp/khaltest/config:
[calendars]

[[private]]
path = /tmp/khaltest/private

type = calendar

[locale]
timeformat = %H:%M
dateformat = %Y-%m-%d
longdateformat = %Y-%m-%d
datetimeformat = %Y-%m-%d %H:%M
longdatetimeformat = %Y-%m-%d %H:%M

[default]
default_calendar = private

[sqlite]
path = /tmp/khaltest/khal.db
  1. Run khal --config /tmp/khaltest/config list 2025-09-16 2025-09-16
  2. See the output
Today, 2025-09-16
11:40-12:00 Desayuno ⟳
14:40-15:00 Desayuno ⟳

Expected behavior The output has to be

Today, 2025-09-16
14:40-15:00 Desayuno ⟳

Screenshots If applicable, add screenshots to help explain your problem.

OS, version, khal version and how you installed it:

  • The output of khal --version: khal, version 0.11.3.dev250+g37d9c64db
  • Installation method: khal has been cloned from https://github.com/pimutils/khal.git, and installed via pip install -e .
  • python version: 3.13.7
  • OS: Fedora 41
  • Your khal config file: see the content of the configuration file at the step 2 from the section To Reproduce.
  • The versions of your other python packages:
aiohappyeyeballs==2.6.1
aiohttp==3.12.15
aiosignal==1.4.0
aiostream==0.7.0
attrs==25.3.0
certifi==2025.8.3
charset-normalizer==3.4.3
click==8.2.1
click-log==0.4.0
configobj==5.0.9
freezegun==1.5.5
frozenlist==1.7.0
hypothesis==6.138.17
icalendar==6.3.1
idna==3.10
iniconfig==2.1.0
-e git+https://github.com/pimutils/khal@37d9c64db1b13831327af4b64172d4dfcc9c6998#egg=khal
multidict==6.6.4
packaging==25.0
pluggy==1.6.0
propcache==0.3.2
Pygments==2.19.2
pytest==8.4.2
python-dateutil==2.9.0.post0
pytz==2025.2
pyxdg==0.28
requests==2.32.5
six==1.17.0
sortedcontainers==2.4.0
typing_extensions==4.15.0
tzdata==2025.2
tzlocal==5.3.1
urllib3==2.5.0
urwid==3.0.2
vdirsyncer==0.20.0
wcwidth==0.2.13
yarl==1.20.1

Additional context I actually tried to fix on my own. However, my ICS file doesn't seem aligning the specification.

The DATE-TIME value is set to the time when the original recurrence instance would occur; meaning that if the intent is to change a Friday meeting to Thursday, the DATE-TIME is still set to the original Friday meeting.

In my example the DATE-TIME value of the property RECURRENCE-ID is set to the new value. Do I have an invalid "ics"? If it's valid, do you have an idea how can I identify the event which has to be amended?

Amazing project, BTW.

ANtlord avatar Sep 16 '25 18:09 ANtlord

I created a bash script for hassle-free reproducing. Careful, there is an "rm" command

#!/bin/bash --norc

set -e

DIR=/tmp/khaltest
CALENDAR_DIR="$DIR"/private
CONFIG=$DIR/config
RM="rm"  # rm command
KHAL="khal"

mkdir -p $DIR
mkdir -p $CALENDAR_DIR

cat  > "$CALENDAR_DIR"/8af16f25-ee94-40cb-985d-591e2f3c8f87.ics << EOF
BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.5.3-ose ical4j/3.2.19
BEGIN:VTIMEZONE
TZID:Europe/Dublin
BEGIN:STANDARD
DTSTART:19961027T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
TZNAME:GMT
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19810329T010000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
TZNAME:IST
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:8af16f25-ee94-40cb-985d-591e2f3c8f87
DTSTART;TZID=Europe/Dublin:20250909T114000
DTEND;TZID=Europe/Dublin:20250909T120000
DTSTAMP:20250916T144605Z
EXDATE;TZID=Europe/Dublin:20250913T114000,20250909T114000
RRULE:FREQ=DAILY;INTERVAL=1
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Desayuno
END:VEVENT
BEGIN:VEVENT
UID:8af16f25-ee94-40cb-985d-591e2f3c8f87
RECURRENCE-ID;TZID=Europe/Dublin:20250916T144000
DTSTART;TZID=Europe/Dublin:20250916T144000
DTEND;TZID=Europe/Dublin:20250916T150000
DESCRIPTION:
DTSTAMP:20250916T144605Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Desayuno
END:VEVENT
END:VCALENDAR
EOF

cat > "$CONFIG" << EOF
[calendars]

[[private]]
path = $CALENDAR_DIR

type = calendar

[locale]
timeformat = %H:%M
dateformat = %Y-%m-%d
longdateformat = %Y-%m-%d
datetimeformat = %Y-%m-%d %H:%M
longdatetimeformat = %Y-%m-%d %H:%M

[default]
default_calendar = private

[sqlite]
path = $DIR/khal.db
EOF

"$RM" -f $DIR/khal.db
"$KHAL" --config "$CONFIG" list 2025-09-16 2025-09-16

ANtlord avatar Sep 16 '25 18:09 ANtlord

It appears, that the ICS file is incorrect. I got the conclusion from exporting it to other popular calendar applications. One of them created two events on 2025-09-16, just like Khal. Another failed to read the ICS file and ignored the rescheduling.

ANtlord avatar Sep 19 '25 10:09 ANtlord

Perhaps, there is an issue with the calendar I use on my android device https://github.com/FossifyOrg/Calendar/issues/460

ANtlord avatar Sep 19 '25 11:09 ANtlord