(#1979) test for overridden all day rrule event
This commit is contained in:
@@ -386,7 +386,7 @@ def _expand(
|
||||
time_range_end = time_range_end.replace(tzinfo=None)
|
||||
|
||||
for vevent in vevents_overridden:
|
||||
_strip_single_event(vevent, dt_format)
|
||||
_strip_single_event(vevent, dt_format, all_day_event)
|
||||
|
||||
duration = None
|
||||
if hasattr(base_vevent, "dtend"):
|
||||
@@ -448,7 +448,7 @@ def _expand(
|
||||
.format(max_occurrence))
|
||||
|
||||
_strip_component(vevent_component)
|
||||
_strip_single_event(base_vevent, dt_format)
|
||||
_strip_single_event(base_vevent, dt_format, all_day_event)
|
||||
|
||||
i_overridden = 0
|
||||
|
||||
@@ -565,15 +565,20 @@ def _expand(
|
||||
return element, len(filtered_vevents)
|
||||
|
||||
|
||||
def _convert_timezone(vevent: vobject.icalendar.RecurringComponent,
|
||||
name_prop: str,
|
||||
name_content_line: str):
|
||||
def _convert_timezone(
|
||||
vevent: vobject.icalendar.RecurringComponent,
|
||||
name_prop: str,
|
||||
name_content_line: str,
|
||||
all_day_event: bool = False
|
||||
):
|
||||
prop = getattr(vevent, name_prop, None)
|
||||
if prop:
|
||||
if type(prop.value) is datetime.date:
|
||||
date_time = datetime.datetime.fromordinal(
|
||||
prop.value.toordinal()
|
||||
).replace(tzinfo=datetime.timezone.utc)
|
||||
)
|
||||
if not all_day_event:
|
||||
date_time = date_time.replace(tzinfo=datetime.timezone.utc)
|
||||
else:
|
||||
date_time = prop.value.astimezone(datetime.timezone.utc)
|
||||
|
||||
@@ -588,10 +593,14 @@ def _convert_to_utc(vevent: vobject.icalendar.RecurringComponent,
|
||||
setattr(vevent, name_prop, ContentLine(name=prop.name, value=prop.value.strftime(dt_format), params=[]))
|
||||
|
||||
|
||||
def _strip_single_event(vevent: vobject.icalendar.RecurringComponent, dt_format: str) -> None:
|
||||
_convert_timezone(vevent, 'dtstart', 'DTSTART')
|
||||
_convert_timezone(vevent, 'dtend', 'DTEND')
|
||||
_convert_timezone(vevent, 'recurrence_id', 'RECURRENCE-ID')
|
||||
def _strip_single_event(
|
||||
vevent: vobject.icalendar.RecurringComponent,
|
||||
dt_format: str,
|
||||
all_day_event: bool = False,
|
||||
) -> None:
|
||||
_convert_timezone(vevent, 'dtstart', 'DTSTART', all_day_event)
|
||||
_convert_timezone(vevent, 'dtend', 'DTEND', all_day_event)
|
||||
_convert_timezone(vevent, 'recurrence_id', 'RECURRENCE-ID', all_day_event)
|
||||
|
||||
# There is something strange behaviour during serialization native datetime, so converting manually
|
||||
_convert_to_utc(vevent, 'dtstart', dt_format)
|
||||
|
||||
Reference in New Issue
Block a user