Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
criticallimit opened this issue Sep 17, 2023 · 0 comments

Comments

@criticallimit
Copy link

criticallimit commented Sep 17, 2023

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 criticallimit changed the title All day event not working Events with start-and endtime 00:00 at the same day are always expired and not shown Sep 17, 2023
@criticallimit criticallimit changed the title Events with start-and endtime 00:00 at the same day are always expired and not shown Events with start-and endtime 00:00 at the same day are not shown on due day Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant