ical-sensor-homeassistant icon indicating copy to clipboard operation
ical-sensor-homeassistant copied to clipboard

Events with start-and endtime 00:00 at the same day are not shown on due day

Open criticallimit opened this issue 9 months ago • 0 comments

If a event starts and ends at midnight on the same day (coming from an external iCal that you cant change), the event is not shown in the Calendar on that day, because for iCal it´s expired.

I changed the init.py to:

    def _ical_event_dict(self, start, end, from_date, event):
        """Ensure that events are within the start and end."""

        # Skip this event if it's in the past
        if end.date() < from_date.date():
            _LOGGER.debug("This event has already ended")
            return None
            
        # Check if start date is equal to end date, and both start and end hour are 0
        if (
            start.date() == end.date()
            and start.hour == 0
            and start.minute == 0
            and end.hour == 0
            and end.minute == 0
        ):
            # Set end hour to 23
            end = end.replace(hour=23, minute=59, second=59)

        # Ignore events that ended this midnight.
        if (
            end.date() == from_date.date()
            and end.hour == 0
            and end.minute == 0
            and end.second == 0
        ):
            _LOGGER.debug("This event has already ended")
            return None
        _LOGGER.debug(
            "Start: %s Tzinfo: %s Default: %s StartAs %s",
            str(start),
            str(start.tzinfo),
            dt.DEFAULT_TIME_ZONE,
            start.astimezone(dt.DEFAULT_TIME_ZONE),
        )
        event_dict = {
            "summary": event.get("SUMMARY", "Unknown"),
            "start": start.astimezone(dt.DEFAULT_TIME_ZONE),
            "end": end.astimezone(dt.DEFAULT_TIME_ZONE),
            "location": event.get("LOCATION"),
            "description": event.get("DESCRIPTION"),
            "all_day": self.all_day,
        }
        _LOGGER.debug("Event to add: %s", str(event_dict))
        return event_dict

Now all events where start- and endtime is 00:00 at the same day, are changed to 00:00 - 23:59 and will be shown on the due date

criticallimit avatar Sep 17 '23 08:09 criticallimit