Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Moving Event in a recurring session does not work #62

Closed
NicoHood opened this issue Dec 18, 2021 · 12 comments · Fixed by #65
Closed

bug: Moving Event in a recurring session does not work #62

NicoHood opened this issue Dec 18, 2021 · 12 comments · Fixed by #65
Labels
bug Something isn't working polar

Comments

@NicoHood
Copy link

NicoHood commented Dec 18, 2021

  1. Create a new event on the 26th November 2021 set it to repeat every LAST Friday of the month (not the 4th)
  2. Now go to Dezember 2021 and MOVE (Not delete) the event from the 31th to the 17th dez.
  3. Download the resulting ICS file. The library will still tell you that the 31th is a valid date for that series
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Partyborn Zeitgeist
X-WR-TIMEZONE:Europe/Berlin
X-WR-CALDESC:Alle Events des Zeitgeist Paderborn für den Partyborn Partyala
 rm\nhttps://partyborn.de/partyalarm
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20211217T213000
DTSTAMP:20211218T004508Z
UID:38m812jicsrer5gorh3mlp7qhc@google.com
RECURRENCE-ID;TZID=Europe/Berlin:20211231T213000
CREATED:20211218T004036Z
DESCRIPTION:Jeden letzten Freitag im Monat <a href="https://www.instagram.c
 om/p/CWwxmqbKXsC/">https://www.instagram.com/p/CWwxmqbKXsC/</a>
LAST-MODIFIED:20211218T004234Z
LOCATION:
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:Karaoke
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Europe/Berlin:20211126T213000
DTEND;TZID=Europe/Berlin:20211126T213000
RRULE:FREQ=MONTHLY;BYDAY=-1FR
DTSTAMP:20211218T004508Z
UID:38m812jicsrer5gorh3mlp7qhc@google.com
CREATED:20211218T004036Z
DESCRIPTION:Jeden letzten Freitag im Monat <a href="https://www.instagram.c
 om/p/CWwxmqbKXsC/">https://www.instagram.com/p/CWwxmqbKXsC/</a>
LAST-MODIFIED:20211218T004214Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:Karaoke
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR

We're using [Polar.sh](https://polar.sh/niccokunzmann) so you can upvote and help fund this issue. We receive the funding once the issue is completed & confirmed by you. Thank you in advance for helping prioritize & fund our work. Fund with Polar
@NicoHood NicoHood added the bug Something isn't working label Dec 18, 2021
@NicoHood
Copy link
Author

I was able to work around the issue like this:

# Fix bug with moved recurring event:
# https://github.com/niccokunzmann/python-recurring-ical-events/issues/62
event_start = event['DTSTART'].dt
event_moved = False
for component in ical.walk():
    if component.name == "VEVENT" and component["UID"] == event["UID"]:
        recurrence_id = component.get('RECURRENCE-ID')
        if recurrence_id:
            event_moved = recurrence_id.dt == event_start
            break
if event_moved:
    logging.warning(f'Excluding moved event {event.get("SUMMARY")} because of ical library bug.')
    continue

@niccokunzmann
Copy link
Owner

Thanks for reporting it!

@niccokunzmann
Copy link
Owner

niccokunzmann commented Dec 23, 2021

I created #65 and can reproduce the error. The ICS file looks fine, so I think the is a read bug needing further investigation. Thanks again!

niccokunzmann added a commit that referenced this issue Dec 23, 2021
Moved event not recognized - Issue #62
@niccokunzmann
Copy link
Owner

This fix is included in v0.2.1 upwards.

@Plonq
Copy link
Collaborator

Plonq commented Jun 29, 2023

This doesn't seem completely fixed. I have confirmed the attached ical file works, however, here's an example exported from Google Calendar that doesn't work.

There are two events (one is all-day), each with 3 occurrences, repeated weekly. The second occurrence on each event has been moved back 1 day. Here's what that looks like in Google Calendar:

image

Here it is correctly imported into Apple Calendar:

image

So to summarise, the 15th instance was moved to the 14th, and the 17th was moved to the 16th.

Processing with this lib results in 3 events on the 14th, 15th, and 22nd for the first event, and 16th, 17th, and 24th for the second event. If I had to guess, it's generating the event on the right days (14th and 16th), but instead of replacing the corresponding instances (15th and 17th) it's replacing the first instance (8th and 10th).

Here's the ical on its own:

BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Test Calendar
X-WR-TIMEZONE:Australia/Sydney
BEGIN:VTIMEZONE
TZID:Australia/Sydney
X-LIC-LOCATION:Australia/Sydney
BEGIN:STANDARD
TZOFFSETFROM:+1100
TZOFFSETTO:+1000
TZNAME:AEST
DTSTART:19700405T030000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+1000
TZOFFSETTO:+1100
TZNAME:AEDT
DTSTART:19701004T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20230808T140000
DTEND;TZID=Australia/Sydney:20230808T150000
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230828T135959Z;BYDAY=TU
DTSTAMP:20230629T040023Z
UID:7v3ju5ft4je5iq18nfdk2s3spk@google.com
CREATED:20230629T035454Z
LAST-MODIFIED:20230629T035851Z
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Datetime
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20230814T140000
DTEND;TZID=Australia/Sydney:20230814T150000
DTSTAMP:20230629T040023Z
UID:7v3ju5ft4je5iq18nfdk2s3spk@google.com
RECURRENCE-ID;TZID=Australia/Sydney:20230815T140000
CREATED:20230629T035454Z
LAST-MODIFIED:20230629T035851Z
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Datetime
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20230810
DTEND;VALUE=DATE:20230811
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230830;BYDAY=TH
DTSTAMP:20230629T040023Z
UID:6ep37v20d728v14rcgn17v9is6@google.com
CREATED:20230629T035522Z
LAST-MODIFIED:20230629T035854Z
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:All Day
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20230816
DTEND;VALUE=DATE:20230817
DTSTAMP:20230629T040023Z
UID:6ep37v20d728v14rcgn17v9is6@google.com
RECURRENCE-ID;VALUE=DATE:20230817
CREATED:20230629T035522Z
LAST-MODIFIED:20230629T035854Z
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:All Day
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR

Here's a python script that shows the problem:

from datetime import datetime

import recurring_ical_events
from icalendar.cal import Calendar

content = """BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Test Calendar
X-WR-TIMEZONE:Australia/Sydney
BEGIN:VTIMEZONE
TZID:Australia/Sydney
X-LIC-LOCATION:Australia/Sydney
BEGIN:STANDARD
TZOFFSETFROM:+1100
TZOFFSETTO:+1000
TZNAME:AEST
DTSTART:19700405T030000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+1000
TZOFFSETTO:+1100
TZNAME:AEDT
DTSTART:19701004T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20230808T140000
DTEND;TZID=Australia/Sydney:20230808T150000
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230828T135959Z;BYDAY=TU
DTSTAMP:20230629T040023Z
UID:7v3ju5ft4je5iq18nfdk2s3spk@google.com
CREATED:20230629T035454Z
LAST-MODIFIED:20230629T035851Z
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Datetime
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Australia/Sydney:20230814T140000
DTEND;TZID=Australia/Sydney:20230814T150000
DTSTAMP:20230629T040023Z
UID:7v3ju5ft4je5iq18nfdk2s3spk@google.com
RECURRENCE-ID;TZID=Australia/Sydney:20230815T140000
CREATED:20230629T035454Z
LAST-MODIFIED:20230629T035851Z
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Datetime
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20230810
DTEND;VALUE=DATE:20230811
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230830;BYDAY=TH
DTSTAMP:20230629T040023Z
UID:6ep37v20d728v14rcgn17v9is6@google.com
CREATED:20230629T035522Z
LAST-MODIFIED:20230629T035854Z
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:All Day
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20230816
DTEND;VALUE=DATE:20230817
DTSTAMP:20230629T040023Z
UID:6ep37v20d728v14rcgn17v9is6@google.com
RECURRENCE-ID;VALUE=DATE:20230817
CREATED:20230629T035522Z
LAST-MODIFIED:20230629T035854Z
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:All Day
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
"""

cal = Calendar.from_ical(content)
events = recurring_ical_events.of(cal).between(
    datetime(2023, 8, 1), datetime(2023, 8, 30)
)
for event in events:
    print(event["SUMMARY"], event["DTSTART"].dt)

Script output:

Datetime 2023-08-15 14:00:00+10:00
Datetime 2023-08-22 14:00:00+10:00
Datetime 2023-08-14 14:00:00+10:00
All Day 2023-08-17
All Day 2023-08-24
All Day 2023-08-16

@Plonq Plonq reopened this Jun 29, 2023
@niccokunzmann
Copy link
Owner

niccokunzmann commented Jun 29, 2023 via email

@niccokunzmann
Copy link
Owner

niccokunzmann commented Jul 5, 2023

@Plonq, could you check the PR #112? I wrote tests to reproduce the issue. Which version do you have installed?

version: 2.0.2 output:

Datetime 2023-08-08 14:00:00+10:00
Datetime 2023-08-22 14:00:00+10:00
Datetime 2023-08-14 14:00:00+10:00
All Day 2023-08-10
All Day 2023-08-24
All Day 2023-08-16

@Plonq
Copy link
Collaborator

Plonq commented Jul 5, 2023

@niccokunzmann The tests in that PR pass for me also. I am using 2.0.2 as well. I tracked down the issue to icalendar. Updating from 5.0.2 to 5.0.7 fixed it. I haven't dug into why or what changed in icalendar. If you can reproduce the issue after downgrading, then perhaps recurring-ical-events should depend on >= 5.0.7?

Sorry for the trouble, and thanks for working on this!

@Plonq
Copy link
Collaborator

Plonq commented Jul 7, 2023

Re-closing as this does appear to be fixed after all.

@Plonq Plonq closed this as completed Jul 7, 2023
@niccokunzmann
Copy link
Owner

niccokunzmann commented Jul 7, 2023 via email

@Plonq
Copy link
Collaborator

Plonq commented Jul 9, 2023

Setting version of your dependencies is the correct way to solve this issue I think. It's not just about an upstream bug though, having a dependency without a version means someone could try using a really old version and have nothing work at all. But just in general, if lib A depends on lib B, but only works correctly with version 1.2.3 of lib B, then it should depend on >= 1.2.3 of lib B.

@niccokunzmann
Copy link
Owner

The versions are now set in the requirements file. This was the last condition to close this, I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working polar
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants