chore: sync GovOPlaN module split state
This commit is contained in:
@@ -92,6 +92,8 @@ def parse_vevent_component(calendar: Calendar, event: Event, *, raw_ics: str) ->
|
||||
properties = component_property_records(event)
|
||||
alarms = [component_alarm_record(alarm) for alarm in event.subcomponents if alarm.name == "VALARM"]
|
||||
standard = standard_property_index(properties)
|
||||
if dtend is None and duration_seconds is not None:
|
||||
standard["uses_duration"] = True
|
||||
|
||||
return {
|
||||
"uid": uid,
|
||||
@@ -154,7 +156,9 @@ def event_to_component(event: Any) -> Event:
|
||||
component.add("uid", event.uid)
|
||||
component.add("dtstamp", datetime.now(timezone.utc))
|
||||
component.add("dtstart", event_temporal_value(event.start_at, all_day=event.all_day, timezone_id=event.timezone))
|
||||
if event.end_at is not None:
|
||||
if event_uses_duration(event):
|
||||
component.add("duration", timedelta(seconds=int(event.duration_seconds)))
|
||||
elif event.end_at is not None:
|
||||
component.add("dtend", event_temporal_value(event.end_at, all_day=event.all_day, timezone_id=event.timezone))
|
||||
elif getattr(event, "duration_seconds", None) is not None:
|
||||
component.add("duration", timedelta(seconds=int(event.duration_seconds)))
|
||||
@@ -474,6 +478,16 @@ def metadata_value(event: Any, key: str) -> str | None:
|
||||
return str(value) if value else None
|
||||
|
||||
|
||||
def event_uses_duration(event: Any) -> bool:
|
||||
if getattr(event, "duration_seconds", None) is None:
|
||||
return False
|
||||
raw_metadata = getattr(event, "icalendar", None)
|
||||
if not isinstance(raw_metadata, dict):
|
||||
return False
|
||||
standard = raw_metadata.get("standard")
|
||||
return isinstance(standard, dict) and standard.get("uses_duration") is True
|
||||
|
||||
|
||||
def event_temporal_value(value: datetime, *, all_day: bool, timezone_id: str | None) -> date | datetime:
|
||||
value = normalize_datetime(value)
|
||||
if all_day:
|
||||
|
||||
Reference in New Issue
Block a user