From 83bb2c3b65a9398d528888b7c232bcc026d9c500 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Fri, 23 Jan 2026 16:47:56 +0100 Subject: [PATCH] updated calendar widget to show "today" and "tomorrow" --- glance-system/glance-helper.yaml | 17 +++++++++++++++++ glance-system/glance-kisfenyo.yaml | 4 ++-- glance-system/glance-orsi.yaml | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/glance-system/glance-helper.yaml b/glance-system/glance-helper.yaml index cd7af8a..9b071d2 100644 --- a/glance-system/glance-helper.yaml +++ b/glance-system/glance-helper.yaml @@ -936,6 +936,20 @@ data: # Calendar configuration - loaded from environment CALENDAR_ICAL_URLS = os.getenv("CALENDAR_ICAL_URLS", "") # JSON: {"name": "url", ...} + def _format_relative_date(dt: datetime, tz) -> str: + """Format date as 'Today', 'Tomorrow', or 'Mon 24' style.""" + now = datetime.now(tz) + today = now.date() + tomorrow = today + timedelta(days=1) + event_date = dt.date() + + if event_date == today: + return "Today" + elif event_date == tomorrow: + return "Tomorrow" + else: + return dt.strftime("%b %d") + def _parse_ical_urls() -> dict[str, str]: """Parse CALENDAR_ICAL_URLS environment variable.""" if not CALENDAR_ICAL_URLS: @@ -1047,6 +1061,7 @@ data: "start": occ.isoformat(), "start_unix": int(occ.timestamp()), "start_date": occ.strftime("%b %d"), + "start_date_relative": _format_relative_date(occ, tz), "start_time": occ.strftime("%H:%M"), "start_weekday": occ.strftime("%a"), "end": occ_end.isoformat() if occ_end else None, @@ -1066,6 +1081,7 @@ data: "start": dtstart_val.isoformat(), "start_unix": int(dtstart_val.timestamp()), "start_date": dtstart_val.strftime("%b %d"), + "start_date_relative": _format_relative_date(dtstart_val, tz), "start_time": dtstart_val.strftime("%H:%M"), "start_weekday": dtstart_val.strftime("%a"), "end": dtend_val.isoformat() if dtend_val else None, @@ -1084,6 +1100,7 @@ data: "start": dtstart_val.isoformat(), "start_unix": int(dtstart_val.timestamp()), "start_date": dtstart_val.strftime("%b %d"), + "start_date_relative": _format_relative_date(dtstart_val, tz), "start_time": dtstart_val.strftime("%H:%M"), "start_weekday": dtstart_val.strftime("%a"), "end": dtend_val.isoformat() if dtend_val else None, diff --git a/glance-system/glance-kisfenyo.yaml b/glance-system/glance-kisfenyo.yaml index 18e65e6..d34bb26 100644 --- a/glance-system/glance-kisfenyo.yaml +++ b/glance-system/glance-kisfenyo.yaml @@ -929,7 +929,7 @@ data: {{ $isExtra := ge $i $showCount }} {{ $isAllDay := $e.Bool "is_all_day" }} {{ $title := $e.String "title" }} - {{ $startDate := $e.String "start_date" }} + {{ $startDate := $e.String "start_date_relative" }} {{ $startTime := $e.String "start_time" }}
@@ -948,7 +948,7 @@ data: {{ end }}
{{ if $hasMore }} - + {{ end }} {{ end }} diff --git a/glance-system/glance-orsi.yaml b/glance-system/glance-orsi.yaml index 7c42277..1f1bcb5 100644 --- a/glance-system/glance-orsi.yaml +++ b/glance-system/glance-orsi.yaml @@ -611,7 +611,7 @@ data: widgets: # Calendar Events Widget (Órák & Családi) - type: custom-api - title: Next Events + title: Events Calendar cache: 5m url: http://glance-helper.glance-system.svc.cluster.local:8000/calendar/events parameters: @@ -695,7 +695,7 @@ data: {{ $isAllDay := $e.Bool "is_all_day" }} {{ $calendar := $e.String "calendar" }} {{ $title := $e.String "title" }} - {{ $startDate := $e.String "start_date" }} + {{ $startDate := $e.String "start_date_relative" }} {{ $startTime := $e.String "start_time" }}