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" }}