Skip to content

Commit

Permalink
Fix range with resource_ids. Fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
jabiertxof committed Sep 1, 2024
1 parent e919593 commit 850a75b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion recurring_ical_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def between(self, span_start: Time, span_stop: Time) -> Generator[Occurrence]:
returned_modifications: set[ComponentAdapter] = set()
# NOTE: If in the following line, we get an error, datetime and date
# may still be mixed because RDATE, EXDATE, start and rule.
prev_adapter = None
for start in self.rrule_between(span_start_dt, span_stop_dt):
recurrence_ids = to_recurrence_ids(start)
if (
Expand All @@ -524,7 +525,18 @@ def between(self, span_start: Time, span_stop: Time) -> Generator[Occurrence]:
adapter: ComponentAdapter = get_any(
self.recurrence_id_to_modification, recurrence_ids, self.core
)
if adapter is self.core:
if prev_adapter and adapter is self.core:
stop = get_any(
self.replace_ends,
recurrence_ids,
normalize_pytz(start + self.core.duration),
)
occurrence = Occurrence(
prev_adapter,
self.convert_to_original_type(start),
self.convert_to_original_type(stop),
)
elif adapter is self.core:
stop = get_any(
self.replace_ends,
recurrence_ids,
Expand All @@ -542,6 +554,8 @@ def between(self, span_start: Time, span_stop: Time) -> Generator[Occurrence]:
continue
returned_modifications.add(adapter)
occurrence = Occurrence(adapter)
if adapter.thisandfuture:
prev_adapter = adapter
if occurrence.is_in_span(span_start, span_stop):
yield occurrence
for modification in self.modifications:
Expand Down Expand Up @@ -662,6 +676,18 @@ def recurrence_ids(self) -> RecurrenceIDs:
return ()
return to_recurrence_ids(recurrence_id.dt)

@cached_property
def thisandfuture(self) -> bool:

"""The recurrence ids has a thisand future range property"""
recurrence_id = self._component.get("RECURRENCE-ID")
if recurrence_id is None:
return False
if "RANGE" in recurrence_id.params:
return recurrence_id.params["RANGE"] == "THISANDFUTURE"
return False


def is_modification(self) -> bool:
"""Whether the adapter is a modification."""
return bool(self.recurrence_ids)
Expand Down

0 comments on commit 850a75b

Please sign in to comment.