Skip to content

Commit

Permalink
Update for all day events (#127)
Browse files Browse the repository at this point in the history
* update for all day events

* add fix for RRULE too
  • Loading branch information
tybritten authored Aug 30, 2023
1 parent 38c802b commit 3ec8d2d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
23 changes: 19 additions & 4 deletions custom_components/ical/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,18 @@ def _ical_parser(self, calendar, from_date, to_date):
event["DTSTART"].dt, dt.DEFAULT_TIME_ZONE
)

# If we don't have a DTEND, just use DTSTART
if "DTEND" not in event:
dtend = dtstart
_LOGGER.debug("Event found without end datetime")
if self.all_day:
# if it's an all day event with no endtime listed, we'll assume it ends at 23:59:59
_LOGGER.debug(f"Event {event['SUMMARY']} is flagged as all day, with a start time of {start}.")
dtend = dtstart + timedelta(days=1, seconds=-1)
_LOGGER.debug(f"Setting the end time to {dtend}")
else:
_LOGGER.debug(f"Event {event['SUMMARY']} doesn't have an end but isn't flagged as all day.")
dtend = dtstart
else:
_LOGGER.debug("DTEND in rrule: %s", str(event["DTEND"].dt))
_LOGGER.debug("DTEND in event")
dtend = self._ical_date_fixer(
event["DTEND"].dt, dt.DEFAULT_TIME_ZONE
)
Expand Down Expand Up @@ -329,7 +336,15 @@ def _ical_parser(self, calendar, from_date, to_date):
start = dtstart

if "DTEND" not in event:
dtend = dtstart
_LOGGER.debug("Event found without end datetime")
if self.all_day:
# if it's an all day event with no endtime listed, we'll assume it ends at 23:59:59
_LOGGER.debug(f"Event {event['SUMMARY']} is flagged as all day, with a start time of {start}.")
dtend = dtstart + timedelta(days=1, seconds=-1)
_LOGGER.debug(f"Setting the end time to {dtend}")
else:
_LOGGER.debug(f"Event {event['SUMMARY']} doesn't have an end but isn't flagged as all day.")
dtend = dtstart
else:
_LOGGER.debug("DTEND in event")
dtend = self._ical_date_fixer(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ical/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/tybritten/ical-sensor-homeassistant/issues",
"requirements": [
"icalendar==5.0.4"
"icalendar==5.0.7"
],
"ssdp": [],
"version": "1.6.6",
"version": "1.6.7",
"zeroconf": []
}
4 changes: 2 additions & 2 deletions ical_updater.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sensor.ical": {
"updated_at": "2023-03-38",
"version": "1.6.6",
"updated_at": "2023-08-28",
"version": "1.6.7",
"local_location": "/custom_components/ics/__init__.py",
"remote_location": "https://raw.githubusercontent.com/tybritten/ical-sensor-homeassistant/master/__init__.py",
"visit_repo": "https://github.com/tybritten/ical-sensor-homeassistant/",
Expand Down

0 comments on commit 3ec8d2d

Please sign in to comment.