Skip to content

Commit 3ec8d2d

Browse files
authored
Update for all day events (#127)
* update for all day events * add fix for RRULE too
1 parent 38c802b commit 3ec8d2d

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

custom_components/ical/__init__.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,18 @@ def _ical_parser(self, calendar, from_date, to_date):
191191
event["DTSTART"].dt, dt.DEFAULT_TIME_ZONE
192192
)
193193

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

331338
if "DTEND" not in event:
332-
dtend = dtstart
339+
_LOGGER.debug("Event found without end datetime")
340+
if self.all_day:
341+
# if it's an all day event with no endtime listed, we'll assume it ends at 23:59:59
342+
_LOGGER.debug(f"Event {event['SUMMARY']} is flagged as all day, with a start time of {start}.")
343+
dtend = dtstart + timedelta(days=1, seconds=-1)
344+
_LOGGER.debug(f"Setting the end time to {dtend}")
345+
else:
346+
_LOGGER.debug(f"Event {event['SUMMARY']} doesn't have an end but isn't flagged as all day.")
347+
dtend = dtstart
333348
else:
334349
_LOGGER.debug("DTEND in event")
335350
dtend = self._ical_date_fixer(

custom_components/ical/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"iot_class": "cloud_polling",
1313
"issue_tracker": "https://github.com/tybritten/ical-sensor-homeassistant/issues",
1414
"requirements": [
15-
"icalendar==5.0.4"
15+
"icalendar==5.0.7"
1616
],
1717
"ssdp": [],
18-
"version": "1.6.6",
18+
"version": "1.6.7",
1919
"zeroconf": []
2020
}

ical_updater.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"sensor.ical": {
3-
"updated_at": "2023-03-38",
4-
"version": "1.6.6",
3+
"updated_at": "2023-08-28",
4+
"version": "1.6.7",
55
"local_location": "/custom_components/ics/__init__.py",
66
"remote_location": "https://raw.githubusercontent.com/tybritten/ical-sensor-homeassistant/master/__init__.py",
77
"visit_repo": "https://github.com/tybritten/ical-sensor-homeassistant/",

0 commit comments

Comments
 (0)