kopia lustrzana https://github.com/jazzband/icalevents
fix: allow for non-recurring events with dates
rodzic
8a689348dd
commit
3b0eecfa57
|
@ -360,10 +360,11 @@ def parse_events(
|
|||
e = create_event(component, strict)
|
||||
|
||||
# make rule.between happy and provide from, to points in time that have the same format as dtstart
|
||||
s = component["dtstart"].dt
|
||||
if type(s) is date and e.recurring == False:
|
||||
f, t = start, end
|
||||
elif type(s) is datetime and s.tzinfo:
|
||||
if type(e.start) is date and e.recurring == False:
|
||||
f, t = date(start.year, start.month, start.day), date(
|
||||
end.year, end.month, end.day
|
||||
)
|
||||
elif type(e.start) is datetime and e.start.tzinfo:
|
||||
f = (
|
||||
datetime(
|
||||
start.year,
|
||||
|
@ -371,10 +372,12 @@ def parse_events(
|
|||
start.day,
|
||||
start.hour,
|
||||
start.minute,
|
||||
tzinfo=s.tzinfo,
|
||||
tzinfo=e.start.tzinfo,
|
||||
)
|
||||
if type(start) == datetime
|
||||
else datetime(start.year, start.month, start.day, tzinfo=s.tzinfo)
|
||||
else datetime(
|
||||
start.year, start.month, start.day, tzinfo=e.start.tzinfo
|
||||
)
|
||||
)
|
||||
t = (
|
||||
datetime(
|
||||
|
@ -383,10 +386,10 @@ def parse_events(
|
|||
end.day,
|
||||
end.hour,
|
||||
end.minute,
|
||||
tzinfo=s.tzinfo,
|
||||
tzinfo=e.start.tzinfo,
|
||||
)
|
||||
if type(end) == datetime
|
||||
else datetime(end.year, end.month, end.day, tzinfo=s.tzinfo)
|
||||
else datetime(end.year, end.month, end.day, tzinfo=e.start.tzinfo)
|
||||
)
|
||||
else:
|
||||
f = (
|
||||
|
@ -421,7 +424,7 @@ def parse_events(
|
|||
)
|
||||
else:
|
||||
ecopy = e.copy_to(
|
||||
dt.date() if type(s) is date else dt, e.uid
|
||||
dt.date() if type(e.start) is date else dt, e.uid
|
||||
)
|
||||
found.append(ecopy)
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//6735d90b475eebfc9f111fc66f5e68fa//NONSGML kigkonsult.se iCalcreat
|
||||
or 2.29.14//
|
||||
CALSCALE:GREGORIAN
|
||||
UID:84c4ae71-1eea-49fc-8e32-b551101c0b2d
|
||||
X-WR-CALNAME:Company Holidays
|
||||
BEGIN:VEVENT
|
||||
UID:6200a801-f5f2-4c9d-a0a0-496f2691b19a
|
||||
DTSTAMP:20200814T182712Z
|
||||
CATEGORIES:Company Holidays
|
||||
DESCRIPTION:Holiday (Jul 31)
|
||||
DTSTART;VALUE=DATE:20200731
|
||||
DTEND;VALUE=DATE:20200801
|
||||
SUMMARY:Company Holiday - Studio Closure
|
||||
TRANSP:TRANSPARENT
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
|
@ -945,3 +945,12 @@ class ICalEventsTests(unittest.TestCase):
|
|||
|
||||
self.assertEqual(len(events), 1)
|
||||
self.assertEqual(events[0].end.hour, 8)
|
||||
|
||||
def test_regression_offset_aware_comparison(self):
|
||||
ical = "test/test_data/regression_offset_native.ics"
|
||||
start = datetime(2020, 7, 1)
|
||||
end = datetime(2020, 7, 31)
|
||||
|
||||
events = icalevents.events(file=ical, start=start, end=end, strict=True)
|
||||
|
||||
self.assertEqual(len(events), 1)
|
||||
|
|
Ładowanie…
Reference in New Issue