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: icalendar does wrong date comparison #332

Closed
Akira25 opened this issue Oct 14, 2021 · 1 comment
Closed

bug: icalendar does wrong date comparison #332

Akira25 opened this issue Oct 14, 2021 · 1 comment

Comments

@Akira25
Copy link

Akira25 commented Oct 14, 2021

I've downloaded a ics-file from the internet and read it with icalender. Then I want to extract just an event from that file and process it further.
Unfortunalety, icalendar doesn't transform the information back to ics, as an exception occures there

Minimal code to reproduce the problem:

#!/bin/python

import requests
import icalendar
import caldav


ics_url = "https://parkclub.info/?method=ical&id=9028"
vcal = requests.get(ics_url).text

gcal = icalendar.Calendar.from_ical(vcal)

event = gcal.walk()[1]
print(event.get("DTSTART").dt)
print(event.get("DTEND").dt)

print(event.to_ical())

which gives this output:

2021-10-23 12:00:00+00:00
2021-10-23 16:00:00+00:00
Traceback (most recent call last):
  File "/home/martin/dev/python_parkclub-calendar-scraper/minimal.py", line 17, in <module>
    print(event.to_ical())
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/cal.py", line 426, in to_ical
    content_lines = self.content_lines(sorted=sorted)
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/cal.py", line 415, in content_lines
    cl = self.content_line(name, value, sorted=sorted)
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/cal.py", line 408, in content_line
    return Contentline.from_parts(name, params, value, sorted=sorted)
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/parser.py", line 306, in from_parts
    values = values.to_ical()
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/prop.py", line 260, in to_ical
    return b",".join(dts_ical)
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/prop.py", line 259, in <genexpr>
    dts_ical = (dt.to_ical() for dt in self.dts)
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/prop.py", line 326, in to_ical
    return vPeriod(dt).to_ical()
  File "/home/martin/.local/lib/python3.9/site-packages/icalendar/prop.py", line 520, in __init__
    raise ValueError("Start time is greater than end time")
ValueError: Start time is greater than end time

But it's pretty obvious, that the start-time isn't greater than the end-time.

@semiprime
Copy link
Contributor

It might be that the problem here is with the RDATE in line 12 of the ics file:

RDATE;VALUE=PERIOD:20211120T130000Z/20211020T170000Z,20211211T130000Z/20211211T170000Z

In this RDATE, the first period is 2021-11-20 to 2021-10-20

@jacadzaca jacadzaca closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants