From c5345ee2ca1aeb181f6e6baf5a270421a6835fd3 Mon Sep 17 00:00:00 2001 From: Jeremy Blaker Date: Sat, 11 Oct 2025 18:04:41 -0400 Subject: [PATCH 1/3] Support for all-day events --- apps/upcoming_events/upcoming_events.star | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/apps/upcoming_events/upcoming_events.star b/apps/upcoming_events/upcoming_events.star index 0bd34637cc..6368149242 100644 --- a/apps/upcoming_events/upcoming_events.star +++ b/apps/upcoming_events/upcoming_events.star @@ -24,6 +24,7 @@ def main(config): rep = http.get(url) if rep.status_code != 200: fail("Google Calender request failed with status %d", rep.status_code) + lines = rep.body().split("\n") events = [] @@ -50,7 +51,42 @@ def main(config): timestamp = line.split(":")[1].replace("\x0d", "") dateFormat = "20060102T150405Z" + eventDate = time.parse_time(timestamp, dateFormat, "UTC") + + # For display, convert to local timezone + timezone = config.get("timezone") or "America/New_York" + localEventDate = eventDate.in_location(timezone) + + event["date"] = eventDate # Keep as UTC for comparison + event["formattedDate"] = localEventDate.format("01/02") # Display in local timezone + + if line.startswith("DTSTART;VALUE=DATE:"): + dateString = line.split(":")[1].replace("\x0d", "") + + year = int(dateString[0:4]) + month = int(dateString[4:6]) + day = int(dateString[6:8]) + + # For all-day events, create a timestamp at noon local time to avoid timezone issues timezone = config.get("timezone") or "America/New_York" + + # Create timestamp string manually (avoiding % formatting) + yearStr = str(year) + monthStr = str(month) + dayStr = str(day) + + # Pad with zeros if needed + if len(yearStr) < 4: + yearStr = "0" * (4 - len(yearStr)) + yearStr + if len(monthStr) < 2: + monthStr = "0" + monthStr + if len(dayStr) < 2: + dayStr = "0" + dayStr + + timestamp = yearStr + monthStr + dayStr + "T120000" + + # Parse in local timezone to avoid date shifting + dateFormat = "20060102T150405" eventDate = time.parse_time(timestamp, dateFormat, timezone) event["date"] = eventDate From 792efb8d2ae93e2627dd9d74c19ccc9b9e42426d Mon Sep 17 00:00:00 2001 From: Jeremy Blaker Date: Mon, 13 Oct 2025 12:46:58 -0400 Subject: [PATCH 2/3] Ran linter --- apps/upcoming_events/upcoming_events.star | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/upcoming_events/upcoming_events.star b/apps/upcoming_events/upcoming_events.star index 6368149242..13177c1d92 100644 --- a/apps/upcoming_events/upcoming_events.star +++ b/apps/upcoming_events/upcoming_events.star @@ -52,7 +52,7 @@ def main(config): dateFormat = "20060102T150405Z" eventDate = time.parse_time(timestamp, dateFormat, "UTC") - + # For display, convert to local timezone timezone = config.get("timezone") or "America/New_York" localEventDate = eventDate.in_location(timezone) @@ -62,19 +62,19 @@ def main(config): if line.startswith("DTSTART;VALUE=DATE:"): dateString = line.split(":")[1].replace("\x0d", "") - + year = int(dateString[0:4]) month = int(dateString[4:6]) day = int(dateString[6:8]) - + # For all-day events, create a timestamp at noon local time to avoid timezone issues timezone = config.get("timezone") or "America/New_York" - + # Create timestamp string manually (avoiding % formatting) yearStr = str(year) monthStr = str(month) dayStr = str(day) - + # Pad with zeros if needed if len(yearStr) < 4: yearStr = "0" * (4 - len(yearStr)) + yearStr @@ -82,9 +82,9 @@ def main(config): monthStr = "0" + monthStr if len(dayStr) < 2: dayStr = "0" + dayStr - + timestamp = yearStr + monthStr + dayStr + "T120000" - + # Parse in local timezone to avoid date shifting dateFormat = "20060102T150405" eventDate = time.parse_time(timestamp, dateFormat, timezone) From 150fb9c5d8e116bd74b608cc6ebff644e6ae6d5d Mon Sep 17 00:00:00 2001 From: Jeremy Blaker Date: Mon, 13 Oct 2025 20:42:40 -0400 Subject: [PATCH 3/3] Support for event names containing colons --- apps/upcoming_events/upcoming_events.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/upcoming_events/upcoming_events.star b/apps/upcoming_events/upcoming_events.star index 13177c1d92..f6d226db5c 100644 --- a/apps/upcoming_events/upcoming_events.star +++ b/apps/upcoming_events/upcoming_events.star @@ -45,7 +45,7 @@ def main(config): if creatingEvent: if line.startswith("SUMMARY:"): - event["name"] = line.split(":")[1] + event["name"] = ":".join(line.split(":")[1:]) if line.startswith("DTSTART:"): timestamp = line.split(":")[1].replace("\x0d", "")